Month: June 2015
-
Exercise 39
// global vars int _num = 10; float _angnoise, _radiusnoise; float _xnoise, _ynoise; float _angle = -PI/2; float _radius = 100; float _strokeCol = 254; int _strokeChange = -1; void setup() { size(500, 300); smooth(); frameRate(30); clearBackground(); _angnoise = random(10); _radiusnoise = random(10); _xnoise = random(10); _ynoise = random(10); } void clearBackground() { background(255); }…
-
Exercise 38
now we randomize the radius using the noise() function size(500,300); background(255); strokeWeight(0.5); smooth(); int centX = 250; int centY = 150; float x, y; for (int i = 0; i
-
Exercise 37
size(500,300); background(255); strokeWeight(5); smooth(); float radius = 100; int centX = 250; int centY = 150; stroke(0, 30); noFill(); ellipse(centX,centY,radius*2,radius*2); stroke(20, 50, 70); radius = 10; float x, y; float lastx = -999; float lasty = -999; for (float ang = 0; ang -999) { line(x,y,lastx,lasty); } lastx = x; lasty = y; }
-
Exercise 36
Now let’s apply the same approach to a circle: size(500, 300); background(255); strokeWeight(5); smooth(); float radius = 100; int centX = 250; int centY = 150; stroke(0, 30); noFill(); ellipse(centX, centY, radius*2, radius*2); stroke(20, 50, 70); float x, y; float lastx = -999; float lasty = -999; for (float ang = 0; ang
-
Exercise 35
Now let’s add noise instead of randomizing. the new point will have some reference to the point before it. size(500, 100); background(255); strokeWeight(5); smooth(); stroke(0, 30); line(20, 50, 480, 50); stroke(20, 50, 70); int step = 10; float lastx = -999; float lasty = -999; float ynoise = random(10); float y; for (int x=20; x…
-
Exercise 34
size(500,100); background(255); strokeWeight(5); smooth(); int step = 10; float lastX = -999; float lastY = -999; float y = 50; int borderX = 20; int borderY = 20; for( int x = borderX; x -999) { line(x, y, lastX, lastY); } lastX = x; lastY = y; }
-
Exercise 33
Now let’s animate the circles to move independently. int _num = 10; Circle[] _circleArr = { }; void setup() { size(800, 800); background(255); smooth(); strokeWeight(1); fill(150, 50); drawCircles(); } void draw() { background(255); for (int i=0; i (height+radius)) { y = 0 – radius; } if (y < (0-radius)) { y = height+radius; } drawMe();…
-
Classes & Instances of Dogs
To illustrate the difference between a class and an instance let’s take a look at applying the concept to dogs. Class A class is a definition for a collection of objects. For example, if we define a class for Dogs it would include all the characteristics common to all dogs. The class is a template:…
-
Exercise 32
Instead of just telling Processing to draw a circle, let’s instead create a circle object. The circle object will encapsulate everything there is to know about itself, which at the moment isn’t much more than the x,y of its center point, and its radius. class Circle { float x, y; float radius; color linecol, fillcol;…
-
Exercise 31
Let’s start simple. The following listing creates a script that draws a handful of randomly placed circles every time the mouse is clicked. int _num = 10; void setup() { size(500, 300); background(255); smooth(); strokeWeight(1); fill(150, 50); drawCircles(); } void draw() { } void mouseReleased() { drawCircles(); } void drawCircles() { for (int i=0; i