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

0 Members and 1 Guest are viewing this topic.

Offline The Librarian

  • Moderator
  • Newbie
  • Posts: 39
    • View Profile
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.         _DISPLAY
  20.         CLS
  21.         setSeed _MOUSEX, _MOUSEY
  22.     END IF
  23.  
  24.     DO 'Marsaglia polar method for random gaussian
  25.         u = RND * 2 - 1
  26.         v = RND2 * 2 - 1
  27.         s = u * u + v * v
  28.     LOOP WHILE s >= 1 OR s = 0
  29.     s = SQR(-2 * LOG(s) / s) * 0.5
  30.     u = u * s * 2
  31.     v = v * s * 2
  32.  
  33.     calcInverseJulia u, v, 1
  34.  
  35.     n% = n% + 1
  36.     IF n% = 300 THEN
  37.         n% = 0
  38.         _DISPLAY
  39.     END IF
  40.  
  41. '####################################################################################################################
  42.  
  43. SUB setSeed (x, y)
  44.     cx = (x / _WIDTH - 0.5) * 4
  45.     cy = (0.5 - y / _HEIGHT) * 3
  46.  
  47. '####################################################################################################################
  48.  
  49. SUB calcInverseJulia (x, y, depth%)
  50.     re = x - cx
  51.     im = y - cy
  52.  
  53.     a = SQR(re * re + im * im)
  54.     x = SQR((a + re) * 0.5)
  55.     IF im < 0 THEN y = -SQR((a - re) * 0.5) ELSE y = SQR((a - re) * 0.5)
  56.  
  57.     PSET2 (x / 4 + 0.5) * _WIDTH, (0.5 - y / 3) * _HEIGHT, 0.02
  58.     PSET2 (x / -4 + 0.5) * _WIDTH, (0.5 + y / 3) * _HEIGHT, 0.02
  59.     IF depth% < 32 THEN
  60.         IF RND < 0.5 THEN calcInverseJulia x, y, depth% + 1 ELSE calcInverseJulia -x, -y, depth% + 1
  61.     END IF
  62.  
  63. '####################################################################################################################
  64.  
  65. SUB PSET2 (x, y, i)
  66.     x% = INT(x)
  67.     y% = INT(y)
  68.     dx = x - x%
  69.     dy = y - y%
  70.  
  71.     q3 = dx * dy
  72.     q2 = (1 - dx) * dy
  73.     q1 = dx * (1 - dy)
  74.     q0 = (1 - dx) * (1 - dy)
  75.  
  76.     PSET (x%, y%), (1 - (1 - q0 * i) * (1 - POINT(x%, y%) / 255)) * 255
  77.     PSET (x% + 1, y%), (1 - (1 - q1 * i) * (1 - POINT(x% + 1, y%) / 255)) * 255
  78.     PSET (x%, y% + 1), (1 - (1 - q2 * i) * (1 - POINT(x%, y% + 1) / 255)) * 255
  79.     PSET (x% + 1, y% + 1), (1 - (1 - q3 * i) * (1 - POINT(x% + 1, y% + 1) / 255)) * 255
  80.  
  81. '####################################################################################################################
  82.  
  83.     seed&& = (25214903917&& * seed&& + 11&&) MOD 281474976710656&&
  84.     RND2 = seed&& / 281474976710656&&
  85.  

inversejulia.png
* InverseJulia.bas (Filesize: 2.6 KB, Downloads: 719)
« Last Edit: February 06, 2019, 08:50:18 pm by The Librarian »