IFD:All Hail The Pixels/ProcessingSketches: Difference between revisions

From Medien Wiki
(Created page with "== 17.10.2011 Processing sketches == === P01 Shapes and Relations === <source lang="java"> /* P01 Shapes and Relations This example illustrates how to formulate properties ...")
 
(Added P03 example sketch)
Line 1: Line 1:
== 17.10.2011 Processing sketches ==
== 17.10.2014 Processing sketches ==


=== P01 Shapes and Relations ===
=== P01 Shapes and Relations ===
Line 124: Line 124:
   line(-halfDimension, -halfDimension, halfDimension, halfDimension );
   line(-halfDimension, -halfDimension, halfDimension, halfDimension );
   line( halfDimension, -halfDimension, -halfDimension, halfDimension);
   line( halfDimension, -halfDimension, -halfDimension, halfDimension);
}
</source>
<br /><br />
== 07.11.2014 Processing sketches ==
=== P03 Nested Rects ===
<source lang="java">
/*
P03 Nested Rectangles with a while loop
Demonstration of how to make a repetetive structure using
a while-loop. Here the variable "rectSize" is decreased in
every step and the coordinate system is rotated a little bit
as well. The while-loop is executed as long as the value
of rectSize is larger than zero (rectSize > 0).
*/
size(1000,600);
// variable with the start size of the rectangles structure
int rectSize = 500;
// variable to specify the amount the rectangles are shrinked in each step
int difference = 30;
background(255);
// since all shapes are aligned centered, the center rect mode is used
rectMode(CENTER);
noFill();
// set the origin of the coordinate system to the center of the stage
translate(width/2, height/2);
// continue the following statements within the while-loop as long as the value
// of the variable "rectSize" is larger than 0
while(rectSize > 0){
  //draw a rectangle with the actual size of "rectSize"
  rect(0,0,rectSize,rectSize);
  // for the next loop: decrease the value of "rectSize" by the value of "difference" 
  rectSize = rectSize - difference;
  // rotate the coordinate system by 4 degrees
  rotate(radians(4));
}
}


</source>
</source>
<br /><br />
<br /><br />