FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
    Examples \ Tutorials \ Courses & Workshops
 
   
 
 
Examples for Processing (BETA) version 91+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.



Scale
by Denis Grutze

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.

Created 12 January 2003

   
// Scale 
// by Denis Grutze 

float a = 0.0; 
float s = 0.0; 
 
void setup() 
{ 
  size(200,200); 
  noStroke(); 
  rectMode(CENTER); 
  framerate(30); 
} 
 
void draw() 
{ 
  background(102); 
  
  a = a + 0.04; 
  s = cos(a)*2; 
  
  translate(width/2, height/2); 
  scale(s); 
  fill(51); 
  rect(0, 0, 50, 50); 
  
  translate(75, 0); 
  fill(255); 
  scale(s); 
  rect(0, 0, 50, 50);       
} 
 







   
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info