OK fixed.
We were just 2 steps away from Classic RotoZoom. Incorporate the RotatePoint code into the RotateAndZoomImage sub and add a scale for the Destination points to grow or shrink the radius:
We were just 2 steps away from Classic RotoZoom. Incorporate the RotatePoint code into the RotateAndZoomImage sub and add a scale for the Destination points to grow or shrink the radius:
Code: (Select All)
_Title "Rotate and Zoom from Point perspective" 'b+ 2022-09-08
Screen _NewImage(800, 600, 32)
rotateCenterX = _Width / 2
rotateCenterY = _Height / 2
' OK make a rectangle image 50x100 and rotate it around the center of the screen in 30 degree increments
Line (0, 0)-(49, 99), &HFFFFFF00, BF
rect& = _NewImage(50, 100, 32)
_PutImage , 0, rect&, (0, 0)-(49, 99)
scale = .5
For a = 0 To _Pi(2) - .001 Step _Pi(1 / 12)
Cls
RotateAndZoomImage rotateCenterX, rotateCenterY, rect&, scale, a, 0
Print "Rotated"; _R2D(a); " scaled at:"; scale
scale = scale + .1
Sleep
Next
Sub RotateAndZoomImage (aboutX As Long, aboutY As Long, Img&, xyScale, radianRot, dest&)
Dim px(1 To 4), py(1 To 4), rotx(1 To 4), roty(1 To 4)
w = _Width(Img&) / 2 ' these are 1/2 widths and heights for faster calc of destination coordinates
h = _Height(Img&) / 2
px(1) = aboutX - w: py(1) = aboutY - h
px(2) = aboutX - w: py(2) = aboutY + h
px(3) = aboutX + w: py(3) = aboutY + h
px(4) = aboutX + w: py(4) = aboutY - h
radius = _Hypot(py(1) - aboutY, px(1) - aboutX) ' radius is all the same
For i = 1 To 4
angle = _Atan2(py(i) - aboutY, px(i) - aboutX)
rotA = angle + radianRot
'rotated x, y point
rotx(i) = aboutX + xyScale * radius * Cos(rotA)
roty(i) = aboutY + xyScale * radius * Sin(rotA)
Next
w = _Width(Img&) - 1 'for source coordinates
h = _Height(Img&) - 1
_MapTriangle (0, 0)-(0, h)-(w, h), Img& To(rotx(1), roty(1))-(rotx(2), roty(2))-(rotx(3), roty(3)), dest&
_MapTriangle (0, 0)-(w, 0)-(w, h), Img& To(rotx(1), roty(1))-(rotx(4), roty(4))-(rotx(3), roty(3)), dest&
End Sub
b = b + ...