A very interesting thread that got me to investigate how Rotozoom actually works. An extra slice of raisin pie to Mr. Jarvis (as they used to say in Easyriders mag) for getting it fixed. I never noticed the issue since I never had occasion to use different scale factors.
While picking the SUB apart I noticed that I could tweak it to work with various parts of my typical vector library scheme and my own idiosyncrasies. Here's the work in progress that I've been playing with:
While picking the SUB apart I noticed that I could tweak it to work with various parts of my typical vector library scheme and my own idiosyncrasies. Here's the work in progress that I've been playing with:
Code: (Select All)
TYPE V2
x AS SINGLE
y AS SINGLE
END TYPE
DIM SHARED img&
DIM sp AS V2
SCREEN _NEWIMAGE(1024, 512, 32)
img& = _NEWIMAGE(256, 256, 32)
MakeImage
deg1! = _D2R(1)
sx! = 1 ' X Scale factor
sy! = 1 ' Y Scale factor
redo:
sp.x = 128: sp.y = 256
FOR x% = 0 TO 360
CLS
LINE (0, _HEIGHT * (3 / 4))-(_WIDTH - 1, _HEIGHT * (3 / 4)), &HFFFFFFFF
sp.x = sp.x + (SIN(deg1!) * 128)
sp.y = _HEIGHT * (3 / 4) - (_HEIGHT(img&) / 2) - ABS(COS(_D2R(x%)) * (sy! * 128 - 128))
'sin0=0 sin90=1 sin180=0 sin270=-1
'cos0=1 cos90=0 cos180=-1 cos270=0
RotoZoomV sp, img&, sx!, sy!, x%
_LIMIT 80
_DISPLAY
NEXT x%
INPUT "again? ", a$
IF a$ = "y" THEN GOTO redo
END
SUB RotoZoomV (center AS V2, Image AS LONG, xScale AS SINGLE, yScale AS SINGLE, Rotation AS SINGLE)
'Development progression: Galleon/Bplus/James Jarvis/altered for OldMoses' vector libraries
DIM AS V2 p(3)
W& = _WIDTH(Image): WS& = W& / 2 * xScale
H& = _HEIGHT(Image): HS& = H& / 2 * yScale
rota! = -0.01745329 * Rotation ' convert degrees to radians
FOR i& = 0 TO 3
p(i&).x = WS& * (1 + 2 * (i& < 2)) ' i& < 2 return -1 else return 1
p(i&).y = HS& * (1 + 2 * (i& MOD 3 = 0)) ' i& = 0 or 3 return -1 else return 1
R2_Roto p(i&), rota! ' perform rotation transform
R2_Add p(i&), center, 1 ' add center postition to result
NEXT
_MAPTRIANGLE (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image TO(p(0).x, p(0).y)-(p(1).x, p(1).y)-(p(2).x, p(2).y)
_MAPTRIANGLE (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image TO(p(0).x, p(0).y)-(p(3).x, p(3).y)-(p(2).x, p(2).y)
END SUB 'RotoZoomV
SUB R2_Roto (v AS V2, ang AS SINGLE) 'transform v, rotating by ang radians
s! = SIN(ang)
c! = COS(ang)
x! = v.x: y! = v.y
v.x = x! * c! + y! * s!
v.y = y! * c! - x! * s!
END SUB 'R2_RotZ
SUB R2_Add (v AS V2, s AS V2, scalar AS SINGLE)
v.x = v.x + s.x * scalar
v.y = v.y + s.y * scalar
END SUB 'R2_Add
SUB MakeImage
_DEST img&
x% = _WIDTH: y% = _HEIGHT: x2% = _SHR(x%, 1): y2% = _SHR(y%, 1)
COLOR , &H00000000
CLS
LINE (x2%, y2%)-(x2%, 0), &HFFFFFFFF
LINE (x2%, y2%)-(x% - 1, y2%), &HFFFF0000
LINE (x2%, y2%)-(x2%, y% - 1), &HFF00FF00
LINE (x2%, y2%)-(0, y2%), &HFF0000FF
CIRCLE (x2%, y2%), 127
_DEST 0
END SUB 'MakeImage
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
sha_na_na_na_na_na_na_na_na_na: