float sz = 20; float offsetx = 0; float offsety = 0; boolean virgin = true; void setup(){ size(200,200); frameRate(30); } void draw(){ background(255); if(virgin){ if(mouseX != 0 || mouseY != 0){ virgin = false; } } if(!virgin){ offsetx += ((mouseX-100.0))/-50.0; offsety += ((mouseY-100.0))/-50.0; } else { offsetx += -1.5; offsety += -.75; } offsetx = offsetx % (sz*3); offsety = offsety % (sz*3); if(mousePressed){ if(sz < 200) { sz+= .3;} } else { if(sz > 20) { sz-=.3;} } offsetx = offsetx -20 + sz; offsety = offsety -20 + sz; strokeWeight(2); stroke(200,200,255); for(float x = -200+offsetx; x < 400; x += sz){ line(x,0,x,200); } for(float y = -200+offsety; y < 400; y += sz){ line(0,y,200,y); } for(float x = -200+offsetx; x < 400; x += sz * 3){ for(float y = -200+offsety; y < 400; y += sz * 3){ duckdraw(x,y,sz); } } } void duckdraw(float x, float y, float s){ stroke(0); strokeWeight(3); line(x,y,x-s,y); line(x-s,y,x,y+s); line(x,y+s,x+s,y+s); line(x+s,y+s,x+s,y-s); line(x+s,y-s,x,y-s); line(x,y-s,x,y); line(x+s,y,x+s+s,y-s); line(x+s+s,y-s,x+s,y-s); line(x+(.5*s),y-(.4*s),x+(.5*s),y-(.6*s)); }