Back
| Home
Julia
Fractal
This is an advanced Game-Editor Drawing Demo - meaning only the C-scripts are
provided and you should already know the mechanics of starting a canvas actor,
adding scripts, etc. If you are not at this level, please see the Let's
DRAW! Basic Drawing Tutorial.

JULIA
FRACTAL
//
Simple Julia Fractal
// Based on C code by Karthik Narayanaswami
// http://www.metlin.org/graphics/fractals.html
int
sx=320;
int sy=240;
double xmin=-2;
double xmax=1.25;
double ymin=-1.25;
double
ymax=1.25;
double maxiter=512;
double
old_x;
double fx,fy;
double ix=0.42;
double iy=0.23;
int m;
double
dx=(xmax-xmin)/sx;
double dy=(ymax-ymin)/sy;
int
px;
int py=0;
double x1;
double y1=ymin;
while
(py<sy) {
px=0;
x1=xmin;
py++;
while (px<sx) {
px++;
fx=x1;
fy=y1;
m=0;
do
{
old_x=fx;
fx= fx*fx - fy*fy + ix;
fy= 2*old_x*fy + iy;
m++;
}
while (((fx*fx+fy*fy)<4) && (m<maxiter));
setpen(m,m,m,0,1);
putpixel(px-75,py+30);
x1+=dx;
}
y1+=dy;
}
Fractals
The
frontier where Art and Science meet.

See our new game site