Heya. I've been having a blast learning processing but am having trouble understanding a relatively simple thing.
I don't quite understand how to fill separate shapes (rect, ellipse, etc) with separate fills.
For example: in the code below, there is a rect() that should be filled with white, and another rectangle that should be filled with semi transparent black each time the draw loop completes. In theory, this should create a motion trail effect, but instead it applies one of the fill()s to all rect()s being drawn.
I started out doing everything in the draw loop, then moved things out to separate custom functions, and am now trying to create the different shapes that get different fills with their own object classes.
Any help would be supremely appreciated! Thank you.
Code:colorSquare sq1;
backGround bg1;
void setup(){
size(800,600);
noStroke();
background(0);
sq1 = new colorSquare();
bg1 = new backGround();
}
void draw()
{
sq1.display();
bg1.bgDisplay();
}
class colorSquare
{
void display(){
rect(mouseX, mouseY, 50, 50);
fill (255);
stroke(255);
}
}
class backGround {
void bgDisplay(){
rect(0,0,width,height);
fill(0,0,0,20);
}
}
Similarly, if I try to rotate() just one of the objects, everything is effected. Totally stumped!