class ardZoobieSketchlet extends Sketchlet { float x, y, t, d, m=50, b, h, v, fa=0.1, fb=0.1, aa=8, ab=8, sat=1.0, complexer=1, frequencyMultiplier=0.01, speedMultiplier=10; color colour; color colours[]=new color[257]; float angle[][]=new float[640][480]; float sinArray[]=new float[721]; int flipper=1; float triHeight=6, triWidth=9; int xPos, yPos, c, i; // int drawStyle=LINES; // int drawStyle=QUAD_STRIP; int drawStyle=TRIANGLE_STRIP; float ta, tb, tc, td; float va=0.2, vb=0.2, vc=0.2, vd=0.1; float gf=4; // ENLARGEMENT Wave wave1, wave2; ardZoobieSketchlet(Wave wave1, Wave wave2) { colorMode(HSB, 1.0); this.wave1=wave1; this.wave2=wave2; smooth(); x=0; while (x-10.2) println ("fps: " + t*10000/millis()); x=0; background(0); while (x<44) { y=0; if (drawStyle==LINES) { beginShape(TRIANGLE_STRIP); } else if (drawStyle==QUAD_STRIP) { beginShape(QUAD_STRIP); } else if (drawStyle==TRIANGLE_STRIP) { beginShape(TRIANGLE_STRIP); } while (y<44) { if (complexer>0) { h=x*gf+0.1*wave1.getAmplitude()* (cosine (((y-x)*wave1.getFrequency()*frequencyMultiplier-ta)))+0.1*wave2.getAmplitude()* (cosine (((y+x)*wave2.getFrequency()*frequencyMultiplier+tb))); v=y*gf+0.1*wave2.getAmplitude()* (sine (((x-y)*wave2.getFrequency()*frequencyMultiplier+tc)))+0.1*wave1.getAmplitude()* (sine (((y+x)*fa-td))); } else { h=x*gf+0.1*wave1.getAmplitude()* (cosine (((x)*wave1.getFrequency()*frequencyMultiplier-ta)))+0.1*wave2.getAmplitude()* (cosine (((y)*wave2.getFrequency()*frequencyMultiplier+tb))); v=y*gf+0.1*wave2.getAmplitude()* (sine (((x)*wave1.getFrequency()*frequencyMultiplier+ta)))+0.1*wave2.getAmplitude()* (sine (((y)*wave2.getFrequency()*frequencyMultiplier-tb))); } xPos=(int)(h-v+width/2); yPos=(int)(h+v+50/gf); /*c=(int)(brightness(get(xPos,yPos)))+8; if (c<0) c=0; if (c>255) c=255; colour=colours[c]; set(xPos,yPos,colour);*/ // stroke(x/200, sat, 1, 0.3); if (drawStyle==LINES) { noFill(); //fill(100); vertex (xPos, yPos); //vertex (xPos+2, yPos); //rect(xPos, yPos, 4, 4) } else { noStroke(); fill(y/200, sat, 1, 0.4); triangle (xPos, yPos, xPos+triWidth/2, yPos+triHeight*flipper, xPos+triWidth, yPos); } //ellipse (xPos, yPos, triWidth, triWidth); //text ("O",xPos, yPos); y+=1.25; } if (drawStyle==LINES) { endShape(); } x+=1.25; flipper=-flipper; /*println("aaaagh"); fill(100); rect(10,10,200,200);*/ } } void readSwitches() { /*if (arduino.digitalRead(2)==arduino.LOW) { sat=0.0; } else {*/ sat=1.0;/* } if (arduino.digitalRead(3)==arduino.HIGH) {*/ complexer=1; /*} else { complexer=-1; }*/ } void keyPressed() { if (key=='s') saveFrame ("zoobie-###.tga"); else if (key=='p') { if (sat==0) sat=0.75; else if (sat==1.0) sat=0.0; else sat=1.0; } else if (key=='g') { if (gf==0) gf=0.5; else if (gf==0.5) gf=1.0; else if (gf==1.0) gf=1.5; else gf=0; } } }