// strange attractor recipe from Mr Clifford A Pickover // Page 163 of Computers, Pattern, Chaos and Beauty float rWidth=4.0, rHeight=4.0, pixelSize; int centreX, centreY; int sWidth=650, sHeight=650; float rxMax = rWidth/2, rxMin = -rxMax, ryMax = rHeight/2, ryMin=-ryMax; int[][] xy; float xxmin, xxmax, yymin, yymax, pres; float a,b,c,d,e; float xinc, yinc; float sc; float x,y,z; int j; boolean flag=false; boolean inverse=false; int blank; void setup() { size(sWidth, sHeight); if(inverse){ blank = 0; }else{ blank=255; } int maxX = sWidth-1; int maxY = sHeight-1; xy = new int[sWidth][sHeight]; pixelSize = max(rWidth/maxX, rHeight/maxY); centreX = maxX/2; centreY = maxY/2; sc=2; xxmin = -2; xxmax =2; yymin = -2; yymax = 2; a=2.24; b =0.43; c = -0.63; d=-2.43; e = 1.0; j=1; x=0; y=0; z=0; background(blank); emptyArray(); } void draw(){ if(!flag){ iterate(true); j++; }else{flag=false;} //drawArray(); } void iterate(boolean drawing){ for(int i=0; i < 100000; i++){ float xx = sin(a*y) - z * cos(b*x); float yy = z * sin(c*x) - cos(d*y); float zz = e * sin(x); x =xx; y = yy; z = zz; if(xx < xxmax & xx > xxmin & yy < yymax && yy > yymin){ // saturate the canvas on each visit, // rather than just plonking a point on int xv = iX(xx); int yv = iY(yy); if(inverse){ if(xy[ xv ][ yv ]<255){ xy[xv][yv]++; } }else{ if(xy[ xv ][ yv ]>0){ xy[xv][yv]--; } } if(drawing){ stroke(xy[xv][yv]); point(xv,yv); } } } } void mouseReleased(){ j=1; int yVal = mouseY; print((float)yVal/650.0); e=(float)yVal/200.0; c=-(float)mouseX/650.0; x=0; y=0; z=0; emptyArray(); background(blank); flag=true; } void emptyArray(){ for(int s =0; s