I wanted to test the seed of the ultra-cool RotoZoom3 Function on my laptop so I put this together to do just that. It shows many gears of different sizes on the screen and rotates each one at different speeds.
I can get about 200 gears going on my laptop before I notice a big slowdown. RotoZoom3 is pretty fast.
The small BAS and PNG image is in the zip below.
- Dav
(50k)
BAS source here for reference -- you will need the image in the zip...
'============
'ROTOGEAR.BAS
'============
'Showcase speed of RotoZoom3 Function(not by me) by
'rotating a large number of gears on the screen in various sizes.
'By Dav, OCT/2021
NumOfGears = 50 'Change number of gears shown on screen here
DIM Gearx
(NumOfGears
), Geary
(NumOfGears
), GearSize
(NumOfGears
) DIM GearRot
(NumOfGears
), GearSpeed
(NumOfGears
)
'Init random values for each gear
GearRot(G) = 1
RotoZoom3 Gearx
(G
), Geary
(G
), gear&
, GearSize
(G
), GearSize
(G
), _D2R(GearRot
(G
)) GearRot
(G
) = GearRot
(G
) + GearSpeed
(G
):
IF GearRot
(G
) > 360 THEN GearRot
(G
) = 1
' Description:
' Started from a mod of Galleon's in Wiki that both scales and rotates an image.
' This version scales the x-axis and y-axis independently allowing rotations of image just by changing X or Y Scales
' making this tightly coded routine a very powerful and versatile image tool.
' This assumes you have set your drawing location with _DEST or default to screen.
' X, Y - is where you want to put the middle of the image
' Image - is the handle assigned with _LOADIMAGE
' xScale, yScale - are shrinkage < 1 or magnification > 1 on the given axis, 1 just uses image size.
' These are multipliers so .5 will create image .5 size on given axis and 2 for twice image size.
' radianRotation is the Angle in Radian units to rotate the image
' note: Radian units for rotation because it matches angle units of other Basic Trig functions
' and saves a little time converting from degree.
' Use the _D2R() function if you prefer to work in degree units for angles.
DIM W&
, H&
, sinr!
, cosr!
, i&
, x2&
, y2&
' variables for image manipulation px(0) = -W& / 2: py(0) = -H& / 2 'left top corner
px(1) = -W& / 2: py(1) = H& / 2 ' left bottom corner
px(2) = W& / 2: py(2) = H& / 2 ' right bottom
px(3) = W& / 2: py(3) = -H& / 2 ' right top
sinr!
= SIN(-radianRotation
): cosr!
= COS(-radianRotation
) ' rotation helpers FOR i&
= 0 TO 3 ' calc new point locations with rotation and zoom x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
px(i&) = x2&: py(i&) = y2&