I’m very new to processing, and did try to follow some tutorials as to how to add a background gradient. However for some reason when I hit play, the gradient is visible but only for a split second at the start. It fades away immediately. Any suggestions? For the top I want the colour (18, 23, 36), and transition into the colour (27, 111, 155) at the bottom. I edited out my attempts to implement the gradient:
float shapeRadius = 120;
float shapeAngle = 0; // angle star begins rotating
int shapeSize = 10; //star size
void setup() {
size(1024,768);
smooth();
noStroke();
background(0);
}
void draw() {
noStroke();
pushMatrix();
fill( 0, 5); // fill with black, low opacity; builds up over old ellipses
rect(0, 0, width, height);
translate(width/2,height/2);
rotate(shapeAngle);
translate(shapeRadius,0);
fill(255);
ellipse(0,0,5,5);
popMatrix();
shapeAngle += .05; // speed
secondStar();
thirdStar();
forthStar();
}
void secondStar(){
noStroke();
pushMatrix();
fill( 0, 5);
rect(0, 0, width, height);
translate(width/2,height/2);
rotate(shapeAngle+90); //angle
translate(shapeRadius+50, 0); //radius
fill(255);
ellipse(0,0,5,5);
popMatrix();
}
void thirdStar(){
noStroke();
pushMatrix();
fill( 0, 5);
rect(0, 0, width, height);
translate(width/2,height/2);
rotate(shapeAngle+20);
translate(shapeRadius+25, 0);
fill(255);
ellipse(0,0,5,5);
popMatrix();
}
void forthStar(){
noStroke();
pushMatrix();
fill( 0, 5);
rect(0, 0, width, height);
translate(width/2,height/2);
rotate(shapeAngle+65);
translate(shapeRadius+65, 0);
fill(255);
ellipse(0,0,5,5);
popMatrix();
}