Open Forum > What's New
ScriptBasic GFX
Support:
Linux ScriptBasic got jealous. :)
The Mandelbrot iterator function will be included in the next ScriptBasic GFX extension module build for Linux and Windows.
--- Code: ---' ScriptBasic GFX - Mandelbrot
IMPORT gfx.inc
s = gfx::Window(640,480,"ScriptBasic GFX Mandelbrot")
ts = gfx::Time()
FOR y = 0 TO 479
FOR x = 0 TO 639
cx = (x - 320) / 120
cy = (y - 240) / 120
rit = gfx::Mandelbrot(cx, cy, 510)
gfx::PixelRGBA s, x, y, rit * 12, rit * 8, rit * 4, 255
NEXT
NEXT
te = gfx::Time()
gfx::stringColor s, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0x000000ff
gfx::Update
WHILE gfx::KeyName(1) <> "+escape"
WEND
gfx::Close
--- End code ---
interface.c (SB GFX ext. module)
--- Code: ---besFUNCTION(gfx_Mandelbrot)
DIM AS double cx, cy, zx, zy, tp;
DIM AS int iter;
besARGUMENTS("rri")
AT cx, AT cy, AT iter
besARGEND
DEF_WHILE (zx * zx + zy * zy < 4 AND iter > 0)
BEGIN_WHILE
tp = zx * zx - zy * zy + cx;
zy = 2 * zx * zy + cy;
zx = tp;
iter = iter - 1;
WEND
besRETURN_LONG(iter);
besEND
--- End code ---
--- Quote ---Critical orbits of complex numbers
Graphically speaking, a function of the form f (x) = x2 + c (where c is a complex number) is a special function under iteration. If you plot the results of the iterations (starting at x = 0) in the complex plane, you obtain what is called the critical orbits of c. If these critical orbits repeat (where the same point in the complex plane repeats), the complex number is in the Mandelbrot set. If the critical orbits simply move further and further away from the origin, the complex numbers are not in the Mandelbrot set.
--- End quote ---
Navigation
[0] Message Index
[*] Previous page
Go to full version