OK @NakedApe perfect demo of _MapTriangle for YOU!
You can Cube any image with this code, see my new Avatar!
Zip with source and image:
Code: (Select All)
_Title "Ape Qubed" ' b+ 2026-01-24
Type xy
As Single x, y
End Type
Screen _NewImage(700, 700, 32)
_ScreenMove 300, 0
Dim sb As Long
sb = _LoadImage("ape.PNG")
' draw cube 3 faces showing
Dim c(0 To 6) As xy
c(0).x = 350: c(0).y = 350
For i = 1 To 6
c(i).x = 350 + 340 * Cos(i * _Pi / 3)
c(i).y = 350 + 340 * Sin(i * _Pi / 3)
Next
'top face
_MapTriangle _Seamless(0, 0)-(_Width(sb) - 1, 0)-(_Width(sb) - 1, _Height(sb) - 1), sb To(c(4).x, c(4).y)-(c(5).x, c(5).y)-(c(6).x, c(6).y), 0
_MapTriangle _Seamless(0, 0)-(0, _Height(sb) - 1)-(_Width(sb) - 1, _Height(sb) - 1), sb To(c(4).x, c(4).y)-(c(0).x, c(0).y)-(c(6).x, c(6).y), 0
'right face
_MapTriangle _Seamless(0, 0)-(_Width(sb) - 1, 0)-(_Width(sb) - 1, _Height(sb) - 1), sb To(c(0).x, c(0).y)-(c(6).x, c(6).y)-(c(1).x, c(1).y), 0
_MapTriangle _Seamless(0, 0)-(0, _Height(sb) - 1)-(_Width(sb) - 1, _Height(sb) - 1), sb To(c(0).x, c(0).y)-(c(2).x, c(2).y)-(c(1).x, c(1).y), 0
ftri c(0).x, c(0).y, c(6).x, c(6).y, c(1).x, c(1).y, &H99000000
ftri c(1).x, c(1).y, c(2).x, c(2).y, c(0).x, c(0).y, &H99000000
' front face
_MapTriangle _Seamless(0, 0)-(_Width(sb) - 1, 0)-(_Width(sb) - 1, _Height(sb) - 1), sb To(c(3).x, c(3).y)-(c(4).x, c(4).y)-(c(0).x, c(0).y), 0
_MapTriangle _Seamless(0, 0)-(0, _Height(sb) - 1)-(_Width(sb) - 1, _Height(sb) - 1), sb To(c(3).x, c(3).y)-(c(2).x, c(2).y)-(c(0).x, c(0).y), 0
ftri c(4).x, c(4).y, c(0).x, c(0).y, c(2).x, c(2).y, &H55000000
ftri c(2).x, c(2).y, c(3).x, c(3).y, c(4).x, c(4).y, &H55000000
Sleep
Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
Dim D As Long
Static a&
D = _Dest
If a& = 0 Then a& = _NewImage(1, 1, 32)
_Dest a&
_DontBlend a& ' '<<<< new 2019-12-16 fix
PSet (0, 0), K
_Blend a& '<<<< new 2019-12-16 fix
_Dest D
_MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
End Sub
You can Cube any image with this code, see my new Avatar!
Zip with source and image:
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

