# Can someone help to check why the circles are not random color?

**URL:** https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176
**Category:** Coding Questions
**Tags:** homework
**Created:** [June 10, 2023, 2:51pm UTC](https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176 "2023-06-10T14:51:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jiuyi91](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jiuyi91](https://discourse.processing.org/u/Jiuyi91)
#### Post date: [June 10, 2023, 2:51pm UTC](https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176/1 "2023-06-10T14:51:09Z")

</div>

let r,g,b,colorFill,R;

let col,canvas2;

function setup() {  
createCanvas(windowWidth, windowHeight);  
canvas2=createGraphics(windowWidth, windowHeight);  
canvas2.clear();

}

function draw() {  
background(col,0,160);  
col=map(mouseX,0,windowWidth,0,255)  
noStroke();  
fill(0);  
rectMode(CENTER);  
rect(mouseX, 200, 20);

noStroke();  
r=random(255);  
g=random(255);  
b=random(255);  
fill(r,g,b);  
XPosition=random(windowWidth),  
YPosition=random(windowHeight),  
canvas2.circle(XPosition,YPosition,20);  
image(canvas2,0,0)  
}

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [June 10, 2023, 3:18pm UTC](https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176/2 "2023-06-10T15:18:38Z")

</div>

sure  
you need

`canvas2.fill(r,g,b);`

---

<div class="post-metadata">

### Author: ![Jiuyi91](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jiuyi91](https://discourse.processing.org/u/Jiuyi91)
#### Post date: [June 10, 2023, 3:21pm UTC](https://discourse.processing.org/t/can-someone-help-to-check-why-the-circles-are-not-random-color/42176/3 "2023-06-10T15:21:56Z")

</div>

Thanks. it works!!! 🤩
