/* Geometry */ int h = 800; int w = 800; float maxX = 5; float maxY = 5; /* Initial conditions */ float x0 = 0.1; float y0 = 0.1; /* Parameters */ float a = -.942868; float b = -1.934392; float c = 1.084818; float d = 1.015843; /* Animation deltas */ float deltaA = 0.01003; float deltaB = 0.01003; float deltaC = 0.01003; float deltaD = 0.01003; /* Which parameters to animate */ boolean updateA = false; boolean updateB = false; boolean updateC = false; boolean updateD = false; int n = 10000; void setup(){ PFont font = loadFont("Serif-24.vlw"); textFont(font); stroke(0); fill(0); size(h,w); frameRate(30); noLoop(); } void draw(){ float x = x0; float y = y0; float x_new; background(255); if(updateA){ a += deltaA; if(a <= -3.0 || a >= 3.0){deltaA = -deltaA;} } if(updateB){ b += deltaB; if(b <= -3.0 || b >= 3.0){deltaB = -deltaB;} } if(updateC){ c += deltaC; if(c <= -3.0 || c >= 3.0){deltaC = -deltaC;} } if(updateD){ d += deltaD; if(d <= -3.0 || d >= 3.0){deltaD = -deltaD;} } for(int i=0;i < 2000;i++){ x_new = sin(a*x) + c*sin(a*y); y = sin(b*x) + d*sin(b*y); x = x_new; } for(int i=0;i < n;i++){ point( (w/(2*maxX)) * (x + maxX) , h - ((h/(2*maxY)) * (y + maxY))); x_new = sin(a*x) + c*sin(a*y); y = sin(b*x) + d*sin(b*y); x = x_new; } text("a = "+a+" b = "+b+" c = "+c+" d = "+d+ " n = "+n, 10,h-10); } void keyTyped() { boolean drawOne = false; switch(key){ case 'a': updateA = !updateA; break; case 'b': updateB = !updateB; break; case 'c': updateC = !updateC; break; case 'd': updateD = !updateD; break; case '+': n += 1000; drawOne = true; break; case '-': n -= 1000; drawOne = true; break; case 'r': a = -.942868; b = -1.934392; c = 1.084818; d = 1.015843; drawOne = true; break; } if(drawOne || updateA || updateB || updateC || updateD){ loop(); }else{ noLoop(); } }