Created
November 28, 2012 04:37
-
-
Save ayato-p/4159039 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
↓参考 | |
http://saeki-ce.xsrv.jp/C_src/mandelbrot01.html | |
↓あとで読む | |
http://azisava.sakura.ne.jp/mandelbrot/algorithm.html | |
*/ | |
int windowX = 800, windowY = 800; | |
double cr1 = -2.3, cr2 = 0.7; | |
double ci1 = -1.5, ci2 = 1.5; | |
double e = 4.0; | |
int imax = 400; | |
void setup(){ | |
size(windowX, windowY); | |
} | |
void draw(){ | |
background(0); | |
double cr,ci,dcr,dci; | |
double zr,zi,zrn,zin; | |
int i,ix,iy,cl,nc; | |
char[] c = new char[128]; | |
dcr=(cr2-cr1)/windowY; | |
dci=(ci2-ci1)/windowX; | |
nc=imax/256; | |
for(ci=ci1,iy=windowX; ci<=ci2; ci+=dci+=dci,iy--){ | |
for(cr=cr1,ix=0; cr<=cr2; cr+=dcr,ix++){ | |
zr=0.0; zi=0.0; | |
for(i=0; i<imax; i++){ | |
zrn=zr*zr-zi*zi+cr; | |
if(zrn>e) break; | |
zin=2.0*zr*zi+ci; | |
if(zin>e) break; | |
zr=zrn; zi=zin; | |
} | |
cl=i/nc; | |
if(cl>255) cl=255; | |
fill(color(cl,cl,cl)); | |
print(ix +","+ iy); | |
point(ix,iy); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment