Getting started with processing
So the first two most important things I learnt was that you need to include and understand void setup and void draw.
Allows you to setup your canvas size that you will be processing you art into. This will only run once.
Void draw is more complicated:
It is a “keyword used to indicate that a function returns no value. Each function must either return a value of a specific datatype or use the keyword void to specify it returns nothing.” – (Fry and Reas, 2014)
“This function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called. draw() is called automatically and should never be called explicitly.” – (Fry and Reas, 2014)
“It should always be controlled with noLoop(), redraw() and loop(). If noLoop() is used to stop the code in draw() from executing, then redraw() will cause the code inside draw() to be executed a single time, and loop() will cause the code inside draw() to resume executing continuously.” – (Fry and Reas, 2014)
In this picture above you can see that the size of the canvas has been set to 800(width) x 800(height) ,rectMode has been used to define what type of start point the rectangle should have for example this is set at centre.
Following on from this a rectangle the size of 400px (width) x 400px (height) will be drawn at half the width and half the height of the canvas.
Now the co-ordinates of where to draw the rectangle have changed to mouseX and mouseY this means that rectangles of size 100px (width) x 100px (height) will be drawn where the cursor of the mouse is in relation to both the x and y axis.
Using fill I have set the colours inside the rectangles there is three different amounts because it is an RGB colour model on the scale of 0 to 255 but as they are set to random it will randomly vary the colours inside the shape.
Then stroke has been used to outline the shape with a colour in this case its red.
Now I have made some changes to my code and using an integer called pos I have created a rectangle that gets wider as it travels in a positive direction across the canvas. In this sketch I have introduced conditionals such as if statements for example if.
“Integers and floats are two different kinds of numerical data. An integer (more commonly called an int) is a number without a decimal point. A float is a floating-point number, which means it is a number that has a decimal place. Floats are used when more precision is needed.” (Fry and Reas, 2014)
I will be using conditionals more in my up and coming blog posts so stay tuned.
FRY, B. AND REAS, C.
draw() \ Language (API) \ Processing 2+
In-text: (Fry and Reas, 2014)
Bibliography: Fry, B. and Reas, C. (2014). draw() \ Language (API) \ Processing 2+. [online] Processing.org. Available at: https://www.processing.org/reference/draw_.html [Accessed 1 Nov. 2014].