Processing Workshop 2

The second processing workshop was based around variables and random commands. A variable is essentially the name given to a value, for example integer for whole numbers, boolean for true/false values, or string for a line of text. We were shown a basic way to integrate each of these variables into code, as shown in the screenshot below:Screen Shot 2014-10-09 at 15.36.34
We were then shown the ‘random’ command which allows a number to be randomly generated depending on the boundaries set within the brackets. This can be used simply as a number generator, or can be used to generate a number corresponding to a colour, thus randomly generating the colour.
We were set a task to produce some code that would generate ten circles on our screen, which are random colours and sizes, and when clicked the screen clears and generates a new set of randomly coloured and sized circles. Using variables and the random function, as well as the code we learnt last week, we were given some time to work through this by ourselves.
I began by specifying that my variable was an integer named “numberOfCirlces”, and then set up the canvas by specifying the size and background colour I wanted. Using the draw function, which is called every frame to constantly loop what is in it, I created the circles I wanted drawn, using ‘random()’ to randomly select the sizes and colours. The ‘while’ function allowed me to limit the number of circles created to 10.  The ‘clearStage’ function essentially redrew my background, and as the draw function is constantly running, my circles were redrawn.
Screen Shot 2014-10-09 at 16.25.36

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