Hello. My problem is that when you press tab (to make the ellipse color be random) it works fine. But, when you change the size of the ellipse (with keys 1-3) the ellipse color isn’t random anymore, but on the last random color it was on. What I want, is that when you change the size of the ellipse, it keeps changing to random colors instead of freezing to one.
PGraphics circles;
//Variables for the size and color of the ball and the text
float right = 50;
float left = 50;
float bin = 0;
float ban = 0;
float bam = 0;
float lop = 110;
void setup()
{
//Setup the window
size(1280, 730);
background(255);
fill(0);
circles = createGraphics(1280, 730);
}
void draw()
{
//Setup
background(255);
noStroke();
noCursor();
//When different keys are pressed they change the color of the ellipse
if (key == TAB)
{
bin = random(255);
ban = random(255);
bam = random(255);
}
//Press keys 0-9 to change size of the ellipse
if (key == '1')
{
right=10;
left=10;
lop=90;
}
if (key == '2')
{
right=20;
left=20;
lop=95;
}
if (key == '3')
{
right=30;
left=30;
lop=100;
}
if (key == ' ')
{
background(255);
circles.beginDraw();
circles.background(255);
circles.endDraw();
}
//If mouse is pressed, then draw
if (mousePressed)
{
circles.beginDraw();
circles.noStroke();
circles.fill(bin, ban, bam);
circles.ellipse(mouseX, mouseY, right, left);
circles.endDraw();
}
//Print the second plane
image(circles, 0, 0);
//If mouse isn't pressed, show the ellipse but dont draw it
fill(bin, ban, bam);
ellipse(mouseX, mouseY, right, left);
}