kklex05
YaBB Newbies
Offline
Posts: 15
old processing version - loop()
Jan 18th , 2008, 5:49pm
Hi, i saw a few old sketches in internet which have no draw()-Methode but it seems at that processing version loop() seems to did the same. How can I change the code to get the application startet in processing version 0132 beta? Kklex ---------------- code -------------------- final int WIDTH=360; final int HEIGHT=360; float blurCount = 0f; float blurCountInc = 1; boolean showM = false; Meanderer m1, m2, m3, m4, m5, m6, m7, m8, m9, m10; void setup() { size(360, 360); background(0, 0, 0); fill(0, 0, 0); rect(0,0,360,360); noStroke(); m1 = new Meanderer(); m2 = new Meanderer(); m3 = new Meanderer(); m4 = new Meanderer(); m5 = new Meanderer(); m6 = new Meanderer(); m7 = new Meanderer(); m8 = new Meanderer(); m9 = new Meanderer(); m10 = new Meanderer(); } void loop() { translate(width/2, height/2); m1.move(); m2.move(); m3.move(); m4.move(); m5.move(); m6.move(); m7.move(); m8.move(); m9.move(); m10.move(); drawLines(); blur(); } void drawLines(){ fill(200, 200, 255, 4); beginShape(POLYGON); curveVertex(m1.x, m1.y); curveVertex(m2.x, m2.y); curveVertex(m3.x, m3.y); curveVertex(m4.x, m4.y); curveVertex(m5.x, m5.y); endShape(); fill(200, 200, 255, 10); beginShape(POLYGON); curveVertex(m5.x, m5.y); curveVertex(m7.x, m7.y); curveVertex(m8.x, m8.y); curveVertex(m9.x, m9.y); curveVertex(m10.x, m10.y); endShape(); } void keyPressed(){ if(key == 'm'){ if(showM){ showM = false; }else{ showM = true; } } } // FULL RGB DIFFUSION FILTER // by SEB void blur() { int index,R,G,B,left,right,top,bottom; for(int j=0;j<WIDTH;j++) { for(int i=0;i<HEIGHT;i++) { index=i*WIDTH+j; // Wraparound offsets if(j>0) left=-1; else left=WIDTH-1; if(j==(WIDTH-1)) right=-WIDTH+1; else right=1; if(i>0) top=-WIDTH; else top=(HEIGHT-1)*WIDTH; if(i==(HEIGHT-1)) bottom=-(HEIGHT-1)*WIDTH; else bottom=WIDTH; // Calculate the sum of n neighbors R=(pixels[left+index]>>16) & 255; // left middle R+=(pixels[right+index]>>16) & 255; // right middle R+=(pixels[index]>>16) & 255; // middle middle R+=(pixels[index+top]>>16) & 255; // middle top R+=(pixels[index+bottom]>>16) & 255; // middle bottom R=(R/5); G=(pixels[left+index]>>8) & 255; // left middle G+=(pixels[right+index]>>8) & 255; // right middle G+=(pixels[index]>>8) & 255; // middle middle G+=(pixels[index+top]>>8) & 255; // middle top G+=(pixels[index+bottom]>>8) & 255; // middle bottom G=(G/5); B=pixels[left+index] & 255; // left middle B+=pixels[right+index] & 255; // right middle B+=(pixels[index] & 255); // middle middle B+=pixels[index+top] & 255; // middle top B+=pixels[index+bottom] & 255; // middle bottom B=(B/5); pixels[index]=(R<<16)+(G<<8)+B; } } } // MEANDERER CLASS // BY FLIGHT404 class Meanderer{ float x = 0; float y = 0; float z = 0; float xVel = random(-4.0f, 4.0f); float yVel = random(-4.0f, 4.0f); float zVel = random(-4.0f, 4.0f); float left, right, top, bottom, back, front; float xDelta, yDelta, zDelta; float dimension = 150; float xMax = 4; float yMax = 4; float zMax = 4; float dim; float boundary = 400; int identity; Meanderer(){} void move(){ left = -dimension; right = dimension; top = -dimension; bottom = dimension; back = -dimension; front = dimension; findXLimits(x, left, right); findYLimits(y, top, bottom); findZLimits(z, back, front); x += xVel; y += yVel; z += zVel; } void findXLimits(float xPos, float lower, float upper){ if (xPos < lower){ xDelta = random(0.0f, 1.0f); } else if (xPos > upper){ xDelta = random(-1.0f, 0.0f); } else { xDelta = random(0.0f, 1.0f) - random(0.0f, 1.0f); } xVel += xDelta; xVel = constrain(xVel, -xMax, xMax); } void findYLimits(float yPos, float lower, float upper){ if (yPos < lower){ yDelta = random(0.0f, 1.0f); } else if (yPos > upper){ yDelta = random(-1.0f, 0.0f); } else { yDelta = random(0.0f, 1.0f) - random(0.0f, 1.0f); } yVel += yDelta; yVel = constrain(yVel, -yMax, yMax); } void findZLimits(float zPos, float lower, float upper){ if (zPos < lower){ zDelta = random(0.0f, 1.0f); } else if (zPos > upper){ zDelta = random(-1.0f, 0.0f); } else { zDelta = random(0.0f, 1.0f) - random(0.0f, 1.0f); } zVel += zDelta; zVel = constrain(zVel, -zMax, zMax); } float zVar; }