Coding for Creative Practice Week 8: For Loops

Creating an Array:
In the week 8 class, we learnt how to create for loops and arrays.

Arrays are an alternative way of defining variables that allow multiple variables to be quickly declared.

A For Loop is a block of code which allow a certain action to be performed continuously in a variably controlled fashion.

Example of Array:

float [ ] energyArray = {19.8, 29.8, 10.2, 5}

// allows you to have multiple values within the ‘{ }’ under one name (energyArray in this case).

ellipse(width/2, height/2, energyArray[1], energyArray [2])

// energyArray[1] = 19.8 as it the first value in the array above.
energyArray [2] = 29.8 etc.

Example of For Loop:

 

for (int i = 0; i<3; i++ ){
}

Variable = ‘int i = 0;’ – this is the iterator constructor.
Conditional = ‘i<3;’ – This is the condition, i.e. if ‘i’ is greater than 3, ‘i’ will repeat if the loop if equal to 0,1,2,3 then ignore the loop once ‘i’ is greater than 3.
Iterator = ‘i++’ What happens each time it runs e.g +1 in this case.

Assignment:
After some more research I have found the statistics for the global suicide rates per country on the WHO (World Health Organisation) http://www.who.int/mental_health/evidence/atlas/profiles/en/
I have decided to develop my idea to incorporate multiple countries statistics into my design. To do this I am going to set up my canvas almost like a graph where I plot the points of the different age groups and there percentage per populous of the differing countries suicide rate. From the points plotted I would join them all together through code in processing so they created a geometric like outline shape. I would do this for a few countries and change the could of the stroke so it would be able to see the differences in the rate of suicide per country, with in easy comparison.

Below is something similar that would occur from my code.

42236860b0af20880603045fb0779900--generative-art-september-

 

Sources for Statistic input:
http://www.nationmaster.com/country-info/stats/Crime/Suicide-rates/Ages-15–24

http://www.stats.govt.nz/browse_for_stats/snapshots-of-nz/nz-social-indicators/Home/Health/suicide.aspx

http://apps.who.int/gho/data/node.main.MHSUICIDE

http://apps.who.int/gho/data/node.sdg.3-4-viz-2?lang=en

Leave a comment

Create a website or blog at WordPress.com

Up ↑