_TITLE "Bubbly Wonderment"
' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2024.09.10.01.33]) on 2025.01.04 at 21:26 (Coordinated Universal Time)
' This program by Charlie Veniot ia a port and mod of QB64 / QBJS program by issues37
' changes noted with a "🔖"

'🔖 SCREEN 12, switching to RGB and custom screen dimensions
  SCREEN _newimage(1000,1000,27)

'🔖 CONST PI = 3.14159
  ' use BAM's built-in _PI constant

'🔖 radius was 100 and points was 300
  CONST radius = 140
  CONST points = 4000

DIM x(points)
DIM y(points)
DIM z(points)
DIM rx(points)
DIM ry(points)
DIM rz(points)
DIM px(points)
DIM py(points)

FOR i = 1 TO points

    theta = RND * 2 * _PI: phi = RND * _PI

    x(i) = radius * SIN(phi) * COS(theta)
    y(i) = radius * SIN(phi) * SIN(theta)
    z(i) = radius * COS(phi)

NEXT i

angleX = 0
angleY = 0
angleZ = 0

DO
    CLS

    FOR i = 1 TO points

        ry(i) = y(i) * COS(angleX) - z(i) * SIN(angleX)
        rz(i) = y(i) * SIN(angleX) + z(i) * COS(angleX)
        rx(i) = x(i)

        temp = rx(i) * COS(angleY) + rz(i) * SIN(angleY)
        rz(i) = -rx(i) * SIN(angleY) + rz(i) * COS(angleY)
        rx(i) = temp

        temp = rx(i) * COS(angleZ) - ry(i) * SIN(angleZ)
        ry(i) = rx(i) * SIN(angleZ) + ry(i) * COS(angleZ)
        rx(i) = temp

        distance = 150
        scale = distance / (distance + rz(i))
        px(i) = rx(i) * scale + 320
        py(i) = ry(i) * scale + 240

        '🔖 PSET (px(i), py(i)), cColor: switching to CIRCLE with changing radius, RGB color, and thick border
          s% = INT(scale*2)
          CIRCLE (px(i) + 180, py(i) + 240), s%, _RGB( 255, 254, 0), , , ,T

    NEXT i

    angleX = angleX + .008
    angleY = angleY + .012
    angleZ = angleZ + .004

    '🔖 _LIMIT 30: BAM ignores _LIMIT, so changing to SLEEP
    SLEEP 0.025
    _DISPLAY

LOOP