Friday 28 November 2008

Starting to Process


I finally managed to pick up the book from Waterstones.
I am basically playing with the program but thinking along the lines of explaining the basic programming concepts in Processing.
To start with, I thought I would look at a very simple program that involves a lot of repetition and cant easily be extended.

//create ellipses
ellipse(xpos, ypos, 10, 10);
ellipse(xpos, ypos, 20, 20);
ellipse(xpos, ypos, 30, 30);
ellipse(xpos, ypos, 40, 40);
ellipse(xpos, ypos, 50, 50);


The code could first be moved to a function with no return value.
A for next loop could could be used to specify the diameter of the circle.
An if statement could be used to stop the loop when the diameter is greater than the height/width of window.
This could be replaced with a while loop and later by a do while loop.
A hypnotical effect could be produced by changing the colour of the stroke as it draws each circle.
It could be demonstrated how easy it is to change all the circles by changing only one value eg stroke weight/gap etc.
Finally a function that accepts parameters and returns an array of circles could be demonstrated.

No comments:

Post a Comment