Mandelbrot set: Difference between revisions
Content added Content deleted
(added BASIC) |
|||
Line 3: | Line 3: | ||
[[Category:Raster graphics operations]] |
[[Category:Raster graphics operations]] |
||
{{task|Fractals}}Generate and draw the [[wp:Mandelbrot set|Mandelbrot set]]. |
{{task|Fractals}}Generate and draw the [[wp:Mandelbrot set|Mandelbrot set]]. |
||
=={{header|BASIC}}== |
|||
This is almost exactly the same as the pseudocode from [[wp:Mandelbrot set#For_programmers|the Wikipedia entry's "For programmers" section]] (which it's closely based on, of course). The image generated is very blocky ("low-res") due to the selected video mode, but it's fairly accurate. |
|||
<lang qbasic> |
|||
SCREEN 13 |
|||
WINDOW (-2, 1.5)-(2, -1.5) |
|||
FOR x0 = -2 TO 2 STEP .01 |
|||
FOR y0 = -1.5 TO 1.5 STEP .01 |
|||
x = 0 |
|||
y = 0 |
|||
iteration = 0 |
|||
maxIteration = 223 |
|||
WHILE (x * x + y * y <= (2 * 2) AND iteration < maxIteration) |
|||
xtemp = x * x - y * y + x0 |
|||
y = 2 * x * y + y0 |
|||
x = xtemp |
|||
iteration = iteration + 1 |
|||
WEND |
|||
IF iteration <> maxIteration THEN |
|||
c = iteration |
|||
ELSE |
|||
c = 0 |
|||
END IF |
|||
PSET (x0, y0), c + 32 |
|||
NEXT |
|||
NEXT |
|||
</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |