Newbie alert - count up then down then up continuously (stroke glow)
in
Programming Questions
•
6 months ago
Hi there,
Coding amateur here in need of some help!
I want the stroke of my shape to cycle between black(0) and white(255) continuously. I am stuck with the logic for this.
So far I have used a boolean variable of 'ascending' for when the stroke var colour is ascending, and using an if statement to cycle the colour up by increments of one if ascending is true. I have also managed to make ascending to become false when the stroke colour reaches 255 (white).
I now want to make the colour decrease when it hits 255 but can't seem to get this to work. Please help!
- b
- boolean ascending = true;
- int colour = 0;
- void setup()
- {
- size(800, 800);
- strokeWeight(5);
- }
- void draw()
- {
- if (ascending); {
- stroke(colour++);
- if (colour == 255)
- {
- ascending =false; }
- rect(200,200,200,200);
- }
- println(colour);
- println(ascending);
- }
1