Bplus learns a new trick, he hopes to treat you with:
_TITLE "Fake sphere mapping mod 2 2018-10-31 B+"
CONST WW = 800
CONST WH = 600
SCREEN _NEWIMAGE(WW, WH, 32)
map& = _NEWIMAGE(WW, WH, 32)
_DEST map&
LINE (0, 0)-(WW, WH), _RGB32(200, 100, 0), BF
FOR i = 0 TO WW STEP WW / 12
LINE (i, 0)-(i + 1, WH), _RGB32(0, 0, 0), BF
NEXT
k~& = _RGB32(255, 255, 0)
ftri map&, WW / 2 - 100, WH / 3, WW / 2 - 100 - 25, WH / 3 + 50, WW / 2 - 100 + 25, WH / 3 + 50, k~&
ftri map&, WW / 2 + 100, WH / 3, WW / 2 + 100 - 25, WH / 3 + 50, WW / 2 + 100 + 25, WH / 3 + 50, k~&
ftri map&, WW / 2 - 25, WH / 3 + 100, WW / 2, WH / 3 + 150, WW / 2 + 25, WH / 3 + 100, k~&
ftri map&, WW / 2 - 50, WH / 3 + 125, WW / 2 - 55, WH / 3 + 130, WW / 2 - 200, WH / 3 + 80, k~&
ftri map&, WW / 2 + 50, WH / 3 + 125, WW / 2 + 55, WH / 3 + 130, WW / 2 + 200, WH / 3 + 80, k~&
ftri map&, WW / 2 - 60, WH / 3 + 140, WW / 2 - 60, WH / 3 + 145, WW / 2 - 220, WH / 3 + 140, k~&
ftri map&, WW / 2 + 60, WH / 3 + 140, WW / 2 + 60, WH / 3 + 145, WW / 2 + 220, WH / 3 + 140, k~&
ftri map&, WW / 2 - 60, WH / 3 + 160, WW / 2 - 55, WH / 3 + 165, WW / 2 - 220, WH / 3 + 210, k~&
ftri map&, WW / 2 + 60, WH / 3 + 160, WW / 2 + 55, WH / 3 + 165, WW / 2 + 220, WH / 3 + 210, k~&
_DEST 0
_PUTIMAGE , map&
r = WH / 3
xc = WW / 2
yc = WH / 2
xo = 0
COLOR , _RGB32(40, 0, 68)
DO
CLS
FOR y = -r TO r
x1 = SQR(r * r - y * y)
tv = (_ASIN(y / r) + 1.5) / 3
FOR x = -x1 + 1 TO x1
tu = (_ASIN(x / x1) + 1.5) / 6
_SOURCE map&
pc~& = POINT((xo + tu * WW) MOD WW, tv * WH)
_DEST 0
PSET (x + xc, y + yc), pc~&
NEXT x
NEXT y
xo = xo + 1
xo = xo MOD WW
_DISPLAY
_LIMIT 60
LOOP
' found at QB64.net: http://www.qb64.net/forum/index.php?topic=14425.0
SUB ftri (d&, x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
a& = _NEWIMAGE(1, 1, 32)
_DEST a&
PSET (0, 0), K
_DEST d&
_MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
_FREEIMAGE a& '<<< this is important!
END SUB