Processing – Nested Loops and rotation

13 Oct

In our latest processing work we learnt about the use of rotation and nested loops. The nested loop that we created allowed us to create a semi opaque grayscale tiled background. This effect was created using the code below;

Nested for loop

Nested for loop

Tiled grayscale background

Tiled grayscale background

When then went on to create a rotating graphic display to do this we used both the translate and rotate functions. First we had to change the rotation origin point. To do this we used the the translate function and set the x and y value to half width and half height, This sets the origin to the center of the canvas. Then we created the rectangle with a random hue that changes each frame. Finally we used a if mouse pressed function that saves the current frame to a png file. Below are two examples of outcomes that I made using these principles.

Processing code

Processing code

Ellipse

Ellipse

Rectangle

Rectangle

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: