garthpaine
YaBB Newbies
Offline
Posts: 3
Australia
Simple beginner question
Oct 1st , 2007, 6:11am
The following code only seems to draw to the screen every time the central fill colur (fillColour) changes in the for loop in draw(), and yet in draw() I call myDrawing() on every loop of the for(). I also note that when fillColour2 is printed to the console it comes twice, like this is being called twice, when I only expect it to be called once per iteration of the for(). Could someone more experienced than I with Processing point out the error of my ways? I want to draw all 4 ellipses every cycle, changing the fill and stroke colours for each ellipse, with the exception of the inner ellipse which I want to change the fill colour for only every "centreCycles" around. Thanks in advance, Garth float x; int centreY; int centreX; float fillColour = 0; int centreCycles = 50; void setup() { size(1200, 800); x = width/4.5; centreY = height/2; centreX = width/2; background(0); //frameRate(12); } void draw() { smooth(); strokeWeight(8); for (int i = 0; i < centreCycles; i++) { if (i < (centreCycles - 1)) { myDrawing(); //println("fillColour: " + fillColour); } else { myDrawing(); fillColour = (random(255)); println("fillColour2: " + fillColour);} } } void myDrawing() { for (int i = 4; i > 0; i--) { stroke(204, random(255), 0); fill(204, random(255), 0); ellipse(centreX, centreY, x*i, x*(i-1));} stroke(random(255), 102, 0); fill(fillColour); ellipse(centreX, centreY, x, x); }