/** * Synthesis 3: Motion and Arrays * Chronodraw by Andreas Gysin (www.ertdfgcvb.ch) * p. 373 */ int hquads = 23; int vquads = 1; int quadwidth = 38; int quadheight = 250; int buflength = 200; int framestep = 4; int framerest = 2; boolean fat = false; boolean grid = true; int btnresomulti = 2; int btnreso = 23; int btnheight; int framecounter = 0; PImage[] bitlist = new PImage[buflength]; PImage blank = new PImage(); int currentpic = buflength - 1; void setup() { size(quadwidth * hquads, quadheight * vquads); blank.width = quadwidth; blank.height = quadheight; blank.pixels = new color[quadwidth*quadheight]; for (int j=0; j= 0) && (mouseX < width) && (mouseY >= 0) && (mouseY < height)){ drawline(mouseX, mouseY, pmouseX, pmouseY); if (fat) { drawthickline(mouseX, mouseY, pmouseX, pmouseY, 2); drawdot(mouseX+1, mouseY); drawdot(mouseX, mouseY+1); drawdot(mouseX, mouseY-1); drawdot(mouseX-1, mouseY); drawdot(mouseX+1, mouseY-1); drawdot(mouseX+1, mouseY+1); drawdot(mouseX-1, mouseY-1); drawdot(mouseX-1, mouseY+1); } } } // draw frames int p = currentpic; for (int j=0; j= framerest) { framecounter = 0; currentpic--; if (currentpic < 0) { currentpic = buflength - 1; } } // btncheck if (keyPressed && key==' ') { btnheight = height / 2; if (mouseY < btnheight && mouseY >=0){ framestep = - int(btnreso / 2) + int(mouseX/(width/btnreso)); //println(framestep); } else if (mouseY > btnheight && mouseY < height){ framerest = int(mouseX/(width/btnreso))*btnresomulti; } } else { btnheight = 8; } // drawgrid if (grid) { drawgrid(); } // drawbtn1 noStroke(); fill(0,0,255,60); int btnxoffset = width/btnreso * (btnreso / 2 + framestep); rect(btnxoffset, 0, width/btnreso, btnheight); // drawbtn2 fill(255,0,0,60); btnxoffset = width/btnreso * framerest / btnresomulti; rect(btnxoffset, height - btnheight, width/btnreso, btnheight); } void clearall(){ for (int i=0; i=sizey) { y=sizex>>1; for(int i=0;i=sizex) { y-=sizex; county+=incy; } countx+=incx; drawdot(countx, county); } } else { x=sizey>>1; for(int i=0;i=sizey) { x-=sizey; countx+=incx; } county+=incy; drawdot(countx, county); } } } //idem void drawthickline(int x1, int y1, int x2, int y2, int thickness) { int dX = x2 - x1; int dY = y2 - y1; double lineLength = Math.sqrt(dX * dX + dY * dY); double scale = (double)(thickness) / (2 * lineLength); double ddx = -scale * (double)dY; double ddy = scale * (double)dX; ddx += (ddx > 0) ? 0.5 : -0.5; ddy += (ddy > 0) ? 0.5 : -0.5; int dx = (int)ddx; int dy = (int)ddy; int xPoints[] = new int[4]; int yPoints[] = new int[4]; xPoints[0] = x1 + dx; yPoints[0] = y1 + dy; xPoints[1] = x1 - dx; yPoints[1] = y1 - dy; xPoints[2] = x2 - dx; yPoints[2] = y2 - dy; xPoints[3] = x2 + dx; yPoints[3] = y2 + dy; drawline(xPoints[0], yPoints[0], xPoints[1], yPoints[1]); drawline(xPoints[1], yPoints[1], xPoints[2], yPoints[2]); drawline(xPoints[2], yPoints[2], xPoints[3], yPoints[3]); drawline(xPoints[3], yPoints[3], xPoints[0], yPoints[0]); }