### Author Topic: Inverse Julia Fractal Explorer by Zom-B  (Read 6517 times)

0 Members and 1 Guest are viewing this topic.

#### The Librarian

• Moderator
• Newbie
• Posts: 39
##### Inverse Julia Fractal Explorer by Zom-B
« on: February 06, 2019, 08:46:40 pm »
Inverse Julia Fractal Explorer

Author: Zom-B
Source: [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] Forum
URL: /forum/index.php?topic=1132.0]http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=1132.0
Version: QB64
Tags: [fractal] [inverse julia set]

Description:
The longer you hold your mouse at one position, the more it starts to glow.

Source Code:
Code: QB64: [Select]
1. DEFSNG A-Z
2.
3. DIM SHARED px, py, cx, cy
4.
5. SCREEN _NEWIMAGE(1024, 768, 256)
6.
7. COLOR 255
8. FOR i% = 0 TO 255
9.     r% = INT((i% / 255) ^ .9323335 * 255)
10.     g% = INT((i% / 255) ^ 1.576838 * 255)
11.     b% = INT((i% / 255) ^ 3.484859 * 255)
12.     _PALETTECOLOR i%, _RGB32(r%, g%, b%)
13.
14. '####################################################################################################################
15.
16. setSeed _MOUSEX, _MOUSEY
17.
18.         n% = 0
19.         setSeed _MOUSEX, _MOUSEY
20.
21.     DO 'Marsaglia polar method for random gaussian
22.         u = RND * 2 - 1
23.         v = RND2 * 2 - 1
24.         s = u * u + v * v
25.     LOOP WHILE s >= 1 OR s = 0
26.     s = SQR(-2 * LOG(s) / s) * 0.5
27.     u = u * s * 2
28.     v = v * s * 2
29.
30.     calcInverseJulia u, v, 1
31.
32.     n% = n% + 1
33.     IF n% = 300 THEN
34.         n% = 0
35.
36. '####################################################################################################################
37.
38. SUB setSeed (x, y)
39.     cx = (x / _WIDTH - 0.5) * 4
40.     cy = (0.5 - y / _HEIGHT) * 3
41.
42. '####################################################################################################################
43.
44. SUB calcInverseJulia (x, y, depth%)
45.     re = x - cx
46.     im = y - cy
47.
48.     a = SQR(re * re + im * im)
49.     x = SQR((a + re) * 0.5)
50.     IF im < 0 THEN y = -SQR((a - re) * 0.5) ELSE y = SQR((a - re) * 0.5)
51.
52.     PSET2 (x / 4 + 0.5) * _WIDTH, (0.5 - y / 3) * _HEIGHT, 0.02
53.     PSET2 (x / -4 + 0.5) * _WIDTH, (0.5 + y / 3) * _HEIGHT, 0.02
54.     IF depth% < 32 THEN
55.         IF RND < 0.5 THEN calcInverseJulia x, y, depth% + 1 ELSE calcInverseJulia -x, -y, depth% + 1
56.
57. '####################################################################################################################
58.
59. SUB PSET2 (x, y, i)
60.     x% = INT(x)
61.     y% = INT(y)
62.     dx = x - x%
63.     dy = y - y%
64.
65.     q3 = dx * dy
66.     q2 = (1 - dx) * dy
67.     q1 = dx * (1 - dy)
68.     q0 = (1 - dx) * (1 - dy)
69.
70.     PSET (x%, y%), (1 - (1 - q0 * i) * (1 - POINT(x%, y%) / 255)) * 255
71.     PSET (x% + 1, y%), (1 - (1 - q1 * i) * (1 - POINT(x% + 1, y%) / 255)) * 255
72.     PSET (x%, y% + 1), (1 - (1 - q2 * i) * (1 - POINT(x%, y% + 1) / 255)) * 255
73.     PSET (x% + 1, y% + 1), (1 - (1 - q3 * i) * (1 - POINT(x% + 1, y% + 1) / 255)) * 255
74.
75. '####################################################################################################################
76.
77.     seed&& = (25214903917&& * seed&& + 11&&) MOD 281474976710656&&
78.     RND2 = seed&& / 281474976710656&&
79.

« Last Edit: February 06, 2019, 08:50:18 pm by The Librarian »