Animating Scale
Remember, you can use variables to control pretty much anything in Processing. This code changes the circle moving example to make it grow.A handy shortcut: instead of saying
circleSize = circleSize + 2, you can just say circleSize += 2.
| x += 10 | x = x + 10 |
| x -= 10 | x = x - 10 |
| x *=10 | x = x * 10 |
| x /= 10 | x = x / 10 |
| x++ | x=x+1 |
| x-- | x=x-1 |
int circleSize=1;
void setup()
{
size(500,300);
}
void draw()
{
background(0);
circleSize += 2;
if ( circleSize > 200)
{
circleSize = 1;
}
ellipse(250,150,circleSize,circleSize);
}
Variations:
- use noFill() to only draw outline circles
- don't clear the screen every time in the draw loop, only when the size gets to 200
- use multiplication instead of addition