Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotozoom without the skew
#16
updated routine(s)
Code: (Select All)
Sub RotoZoom23d (centerX As Long, centerY As Long, Image As Long, xScale As Single, yScale As Single, Rotation As Single)
    Dim px(3) As Single: Dim py(3) As Single
    Wi& = _Width(Image&): Hi& = _Height(Image&)
    W& = Wi& / 2 * xScale
    H& = Hi& / 2 * yScale
    px(0) = -W&: py(0) = -H&: px(1) = -W&: py(1) = H&
    px(2) = W&: py(2) = H&: px(3) = W&: py(3) = -H&
    sinr! = Sin(-0.01745329 * Rotation): cosr! = Cos(-0.01745329 * Rotation)
    For i& = 0 To 3
        x2& = (px(i&) * cosr! + sinr! * py(i&)) + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) + centerY
        px(i&) = x2&: py(i&) = y2&
    Next
    _MapTriangle (0, 0)-(0, Hi& - 1)-(Wi& - 1, Hi& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MapTriangle (0, 0)-(Wi& - 1, 0)-(Wi& - 1, Hi& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub

Sub RotoZoom23ds (centerX As Long, centerY As Long, Image As Long, xScale As Single, yScale As Single, Rotation As Single)
    Dim px(3) As Single: Dim py(3) As Single
    Wi& = _Width(Image&): Hi& = _Height(Image&)
    W& = Wi& / 2 * xScale
    H& = Hi& / 2 * yScale
    px(0) = -W&: py(0) = -H&: px(1) = -W&: py(1) = H&
    px(2) = W&: py(2) = H&: px(3) = W&: py(3) = -H&
    sinr! = Sin(-0.01745329 * Rotation): cosr! = Cos(-0.01745329 * Rotation)
    For i& = 0 To 3
        x2& = (px(i&) * cosr! + sinr! * py(i&)) + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) + centerY
        px(i&) = x2&: py(i&) = y2&
    Next
    _MapTriangle _Seamless(0, 0)-(0, Hi& - 1)-(Wi& - 1, Hi& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MapTriangle _Seamless(0, 0)-(Wi& - 1, 0)-(Wi& - 1, Hi& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub

Code: (Select All)
Sub RotoZoom_23r (centerX As Long, centerY As Long, Image As Long, xScale As Single, yScale As Single, Rotation As Single)
'uses radians
    Dim px(3) As Single: Dim py(3) As Single
    W& = _Width(Image&): H& = _Height(Image&)
    Wp& = W& / 2 * xScale
    Hp& = H& / 2 * yScale
    px(0) = -Wp&: py(0) = -Hp&: px(1) = -Wp&: py(1) = Hp&
    px(2) = Wp&: py(2) = Hp&: px(3) = Wp&: py(3) = -Hp&
    sinr! = Sin(-Rotation): cosr! = Cos(Rotation)
    For i& = 0 To 3
        ' x2& = (px(i&) * cosr! + sinr! * py(i&)) * xScale + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) * yScale + centerY
        x2& = (px(i&) * cosr! + sinr! * py(i&)) + centerX: y2& = (py(i&) * cosr! - px(i&) * sinr!) + centerY
        px(i&) = x2&: py(i&) = y2&
    Next
    _MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
    _MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub
Reply


Messages In This Thread
Rotozoom without the skew - by James D Jarvis - 01-19-2023, 02:50 AM
RE: Rotozoom without the skew - by bplus - 01-19-2023, 05:29 AM
RE: Rotozoom without the skew - by James D Jarvis - 01-19-2023, 03:47 PM
RE: Rotozoom without the skew - by TerryRitchie - 01-19-2023, 03:54 PM
RE: Rotozoom without the skew - by bplus - 01-19-2023, 05:52 PM
RE: Rotozoom without the skew - by bplus - 01-19-2023, 07:02 PM
RE: Rotozoom without the skew - by bplus - 01-20-2023, 05:28 PM
RE: Rotozoom without the skew - by OldMoses - 01-21-2023, 06:17 PM
RE: Rotozoom without the skew - by SMcNeill - 01-21-2023, 07:10 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 07:27 PM
RE: Rotozoom without the skew - by SMcNeill - 01-21-2023, 09:10 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 07:21 PM
RE: Rotozoom without the skew - by bplus - 01-21-2023, 07:23 PM
RE: Rotozoom without the skew - by SMcNeill - 01-21-2023, 09:22 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 11:06 PM
RE: Rotozoom without the skew - by James D Jarvis - 01-21-2023, 11:09 PM
RE: Rotozoom without the skew - by bplus - 01-22-2023, 03:33 PM



Users browsing this thread: 1 Guest(s)