Skip to content

Instantly share code, notes, and snippets.

@GiorgioRegni
Created September 9, 2010 10:18
Show Gist options
  • Save GiorgioRegni/571688 to your computer and use it in GitHub Desktop.
Save GiorgioRegni/571688 to your computer and use it in GitHub Desktop.
For each pixel on the screen do:
{
x0 = scaled x co-ordinate of pixel (must be scaled to lie somewhere in the interval (-2.5 to 1)
y0 = scaled y co-ordinate of pixel (must be scaled to lie somewhere in the interval (-1, 1)
ESCAPE = 2*2
x = 0
y = 0
iteration = 0
MAX_ITERATION = 100
while ( x*x + y*y <= ESCAPE AND iteration < MAX_ITERATION )
{
xtemp = x*x - y*y + x0
y = 2*x*y + y0
x = xtemp
iteration = iteration + 1
}
if ( iteration == max_iteration )
then
color = black
else
color = iteration
plot(x0,y0,color)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment