# How do i change the circle's color when the mouse hovers over it?

**URL:** <https://discourse.processing.org/t/how-do-i-change-the-circles-color-when-the-mouse-hovers-over-it/18226>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [February 28, 2020, 10:00pm UTC](https://discourse.processing.org/t/how-do-i-change-the-circles-color-when-the-mouse-hovers-over-it/18226 "2020-02-28T22:00:01Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![cesca](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@cesca](https://discourse.processing.org/u/cesca)\
**Post date:** [February 28, 2020, 10:24pm UTC](https://discourse.processing.org/t/how-do-i-change-the-circles-color-when-the-mouse-hovers-over-it/18226/5 "2020-02-28T22:24:17Z")

</div>

> [@cesca](#):
>
> var circles = ; setup = () =\> { createCanvas(2145, 1210); for (var c = 0; c \< 2200; c++) { var circle = { x: random(width), y: random (height), r: random (70, 5) }; var overlap = false; var protection = 0; for (var j = 0; j \< circles.length; j++){ var other = circles[j]; var d = dist(circle.x,circle.y, other.x, other.y); if (d \< circle.r + other.r){ overlap = true; } } if (!overlap) { circles.push(circle); } protection++; if (protection \> 10000) { //break; } } } draw = () =\> { for (var i = 0; i \< circles.length; i++){ if(mouseX && mouseY \< circles[i].r){ fill(random(255), random(255), random(255)); strokeWeight(3); stroke(119,136,153); ellipse(circles[i].x, circles[i].y, circles[i].r_2, circles[i].r_2); } else{ fill(255, 255, 255); stroke(119,136,153); strokeWeight(3); ellipse(circles[i].x, circles[i].y, circles[i].r_2, circles[i].r_2); } textSize(300); strokeWeight(5); fill(255, 255, 255); textStyle(BOLD); textFont(‘Varela Round’); text(‘cesca’, 700, 650); } }

LOL i know! i wrote that in my description, but I don’t know how to target the specific circle the mouse is on. i tried “dist(mouseX, mouseY, circle.x, circle.y) \< circle.r” but it doesn’t work.

---

_[View the full topic](https://discourse.processing.org/t/how-do-i-change-the-circles-color-when-the-mouse-hovers-over-it/18226)._
