Africa Day: Using a For Loop to repeat a shape

African Gamers' Day

African Gamers’ Day

Africa Day (25 May) was a nice excuse to celebrate African gamers.

The smaller the image, the closer the fidelity of the shape

The smaller the image, the closer the fidelity of the shape

This example is a bit more complex than the programs we’ve been writing so far, but you can download the code here.

I used a technique explained by Daniel Schiffmnn in this example – basically you read the pixels from a source image as a pixel array. Then you use the colours stored in this array to draw the pixel array of your own sketch. So the images above were generated from this simple black and white silhouette:

This was the source image

This was the source image

If you want to understand how it’s done, it might help you to first refresh your memory of how we can repeat a function a specified number of times using a For Loop.

You can also draw the colours of a source image exactly, as in this example:

Colours copied from source image pixel array

Colours copied from source image pixel array

Advertisements

One thought on “Africa Day: Using a For Loop to repeat a shape

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