Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This processing sketch will provide a scale up down transition for rectangle and circle
/**
* Scale
* by Denis Grutze.
*
* modified by Noel.
*
* Paramenters for the scale() function are values specified
* as decimal percentages. For example, the method call scale(2.0)
* will increase the dimension of the shape by 200 percent.
* Objects always scale from the origin.
*/
float a = 0.0;
float s = 0.0;
float m = 0.0;
void setup() {
size(1280, 720);
noStroke();
rectMode(CENTER);
frameRate(30);
}
void draw() {
background(255);
a = a + 0.04;
s = cos(a)*2;
m = map(s, 0, 100, 0, width);
translate(width/2, height/2);
scale(m);
fill(0);
//ellipse(0,0,150,150);
rect(0, 0, 150, 150);
//saveFrame("img-######.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.