### Author Topic: Inverse Julia fractal explorer  (Read 1086 times)

#### Zom-B

• Hero Member
• Posts: 545
##### Inverse Julia fractal explorer
« on: July 18, 2010, 02:47:39 pm »
The longer you hold your mouse at one position, the more it starts to glow.

Code: [Select]
`DEFSNG A-ZDIM SHARED px, py, cx, cySCREEN _NEWIMAGE(1024, 768, 256)COLOR 255FOR i% = 0 TO 255    r% = INT((i% / 255) ^ .9323335 * 255)    g% = INT((i% / 255) ^ 1.576838 * 255)    b% = INT((i% / 255) ^ 3.484859 * 255)    _PALETTECOLOR i%, _RGB32(r%, g%, b%)NEXT'####################################################################################################################setSeed _MOUSEX, _MOUSEYDO    IF _MOUSEINPUT THEN        n% = 0        _DISPLAY        CLS        setSeed _MOUSEX, _MOUSEY    END IF    DO 'Marsaglia polar method for random gaussian        u = RND * 2 - 1        v = RND2 * 2 - 1        s = u * u + v * v    LOOP WHILE s >= 1 OR s = 0    s = SQR(-2 * LOG(s) / s) * 0.5    u = u * s * 2    v = v * s * 2    calcInverseJulia u, v, 1    n% = n% + 1    IF n% = 300 THEN        n% = 0        _DISPLAY    END IFLOOP'####################################################################################################################SUB setSeed (x, y)cx = (x / _WIDTH - 0.5) * 4cy = (0.5 - y / _HEIGHT) * 3END SUB'####################################################################################################################SUB calcInverseJulia (x, y, depth%)re = x - cxim = y - cya = SQR(re * re + im * im)x = SQR((a + re) * 0.5)IF im < 0 THEN y = -SQR((a - re) * 0.5) ELSE y = SQR((a - re) * 0.5)PSET2 (x / 4 + 0.5) * _WIDTH, (0.5 - y / 3) * _HEIGHT, 0.02PSET2 (x / -4 + 0.5) * _WIDTH, (0.5 + y / 3) * _HEIGHT, 0.02IF depth% < 32 THEN    IF RND < 0.5 THEN calcInverseJulia x, y, depth% + 1 ELSE calcInverseJulia -x, -y, depth% + 1END IFEND SUB'####################################################################################################################SUB PSET2 (x, y, i)x% = INT(x)y% = INT(y)dx = x - x%dy = y - y%q3 = dx * dyq2 = (1 - dx) * dyq1 = dx * (1 - dy)q0 = (1 - dx) * (1 - dy)PSET (x%, y%), (1 - (1 - q0 * i) * (1 - POINT(x%, y%) / 255)) * 255PSET (x% + 1, y%), (1 - (1 - q1 * i) * (1 - POINT(x% + 1, y%) / 255)) * 255PSET (x%, y% + 1), (1 - (1 - q2 * i) * (1 - POINT(x%, y% + 1) / 255)) * 255PSET (x% + 1, y% + 1), (1 - (1 - q3 * i) * (1 - POINT(x% + 1, y% + 1) / 255)) * 255END SUB'####################################################################################################################FUNCTION RND2 STATICseed&& = (25214903917&& * seed&& + 11&&) MOD 281474976710656&&RND2 = seed&& / 281474976710656&&END FUNCTION`