Competition entry winners announced.
Things to do this week update. (http://hingstonbrook.com/COMP1720/)
PDE template: http://hingstonbrook.com/dir/PDEtemplate.txt
Real Programming. Functions.
Ordinate (in order). In java "" denotes a string rather than an integer or float, etc.
Definition: Concatination.
The joining of strings and variables. eg
position = ordinate(5) + "!"; //printing position will print: 5!
Java variable, function: Lowercase first letter and camel-case. //variable, function: protoNinja
Java Class: Uppercase first letter and camel-case. //class: ProtoNinja
Below is the code developed during the lecture.
Note: There is an eye.png art asset that is required for this code to run.
/* ---------------------------------------------------------------------------- BlobPet.pde Intent ~~~~~~ This program is supposed to make an infintee spawning amorphouse-blob pet Designed ~~~~~~~~ baz Aug 2011 Modified ~~~~~~~~ */ // ---------------------------------------------------------------------------- Initialisation // Global (i.e. PApplet-wide) constants and variables PImage mbEye ; //Processing Image (is a class) // ------------------------------------------------- void setup() { size(400, 500) ; background(127) ; mbEye = loadImage("eye.png") ; //Using the loadImage() function smooth() ; //Makes curves look better } // ------------------------------------------------------------------------------ Main methods void draw() { float x = random(50, 350) ; float y = random(50, 450) ; float s = random(50, 120) ; drawBlob(x,y, s, color(256,128,0)) ; } // --------------------------------------------------------------------------- Private methods void drawBlob(float x, float y, float blobSize, color colour) { float eyeHeight = blobSize/4, eyeWidth = blobSize/4 ; noStroke() ; for (int i=1 ; i < blobSize ; i++) { fill(color(red(colour), green(colour), blue(colour), blobSize-i)) ; ellipse(x,y, i,0.6*i) ; } ellipse(x,y, blobSize, blobSize*0.6) ; image(mbEye, (x-eyeWidth/2),(y-eyeHeight/2), eyeWidth,eyeHeight) ; } // ----------------------------------------------------------------------------------- Classes /* classes referenced '''''''''''''''''' - */ // -------------------------------------------------------------------------------------------