I need help with the color change of the dots in the image I created
I added a colorwheel, I create a point with mousepress and drop it to the ground. The color I choose from Colorwheel changes the color of the dots on the whole screen. However, the falling point should stay in the color I chose first, and its color should not change. After changing the color from ColorWheel the new dots should be in the new color.
Note: I do not know the rules such as asking questions and opening topics very well. I’m sorry in advance if I’m missing something.
import controlP5.*;
ControlP5 gui;
color renk;
int liquidity = 10;
int r = 2;
ArrayList <Particle> all = new ArrayList<Particle>();
float[] h;
void setup()
{
size(1000, 600);
gui = new ControlP5(this);
h = new float[width];
noSmooth();
frameRate(60);
background(255);
//fill(255);
gui.addColorWheel("renk", 840, 10, 120)
.setRGB(color(0, 45, 90));
}
void keyPressed()
{
for (int i = 0; i<width; i++)
{
h[i] = 0;
}
}
void draw()
{
rect(-1, -1, width, height);
if (mouseY<height-h[constrain(mouseX, 0, width-1)]&&mousePressed)
{
for (int i = 0; i<40; i++)
{
all.add(new Particle(mouseX, mouseY));
stroke(renk);
}
}
for (int i = 0; i<all.size(); i++)
{
all.get(i).show();
}
for (int i = 0; i<all.size(); i++)
{
if (all.get(i).dead)
{
all.remove(i);
i--;
}
}
for (int i = 0; i<width; i++) //düşen noktaların sadece düştüğü yerde kalması düşerken oluşturduklarının silinmesi için
{
line(i, height, i, height-h[i]);
}
for (int n = 0; n<liquidity; n++) //
{
for (int i = 1; i<width; i++)
{
if (abs(h[i]-h[i-1])>3)
{
float avg = (h[i]+h[i-1])/2;
h[i] = avg;
h[i-1] = avg;
}
}
}
}
class Particle
{
boolean dead = false;
float x, y, vx, vy;
float px, py;
Particle(int xp, int yp)
{
x = xp;
y = yp;
px = x;
py = y;
float d = random(TWO_PI);
float l = random(r/PI, r);
vx = cos(d)*l;
vy = sin(d)*l;
}
void show()
{
//set((int)x, (int)y, color(renk));
line(x, y, px, py);
px = x;
py = y;
x+=vx;
y+=vy;
vy+=0.1;
if (x!=constrain(x, 0, width-1))
{
dead = true;
} else
{
if (y>height-h[(int)x])
{
h[(int)x]+=1;
dead = true;
}
}
}
}