Author Topic: Mandelbrot Set by qbguy  (Read 1963 times)

Offline The Librarian

  • Moderator
Mandelbrot Set by qbguy
« on: March 17, 2018, 09:43:35 AM »
Mandelbrot Set

Author: qbguy
Source: qb64.net Forum
URL: http://www.qb64.net/forum/index.php?topic=121.0
Version: 2008
Tags: [2d], [fractal]

Description:
'public domain, uses qb64's 2d prototype

Source Code:
Code: QB64 [Select]
  1. 'public domain
  2. 'uses qb64's 2d prototype
  3. DEFDBL A-Z
  4. SCREEN _NEWIMAGE(640, 480, 32)
  5. DIM R(15) AS INTEGER, G(15) AS INTEGER, B(15) AS INTEGER
  6. FOR i = 0 TO 15: READ R(i): NEXT
  7. FOR i = 0 TO 15: READ G(i): NEXT
  8. FOR i = 0 TO 15: READ B(i): NEXT
  9. DATA 0,63,63,63,63,63,31,0,0,31,31,31,47,63,63,63
  10. DATA 0,0,15,31,47,63,63,63,63,31,15,0,0,0,0,0
  11. DATA 0,0,0,0,0,0,0,0,31,63,63,63,63,63,42,21
  12.  
  13. real = -2.2: imag = -1.2
  14. incr = 0.005
  15. FOR y = 0 TO 479
  16.     r = real
  17.     FOR x = 0 TO 639
  18.         colour = (64 - mandel(r, imag, 64)) MOD 16
  19.         colour = _RGB32(R(colour) * 4, G(colour) * 4, B(colour) * 4)
  20.         PSET (x, y), colour
  21.         r = r + incr
  22.     NEXT
  23.     imag = imag + incr
  24.  
  25. FUNCTION mandel% (ox, oy, limit)
  26.     x = ox: y = oy
  27.     FOR c% = limit TO 1 STEP -1
  28.         xx = x * x: yy = y * y
  29.         IF xx + yy >= 4 THEN EXIT FOR
  30.         y = x * y * 2 + oy
  31.         x = xx - yy + ox
  32.     NEXT
  33.     mandel = c%
  34.  

« Last Edit: August 08, 2018, 11:16:29 PM by odin »