$TYPECHECK ON
$RESOURCE BMP_RES AS "rapidq.bmp"
CONST PI = 3.141593
CONST True = 1
CONST False = 0
DIM DEGREE AS INTEGER
DEGREE = 0
DECLARE SUB CanvasOnPaint
DECLARE SUB Timer1OnTimer
DIM OffBMP AS QBITMAP
DIM BMP AS QBITMAP
BMP.BMPHandle = BMP_RES
OffBMP.Height = BMP.Height + 100
OffBMP.Width = BMP.Width + 100
DIM ScaleX AS INTEGER, ScaleY AS INTEGER
ScaleX = BMP.Width/2
ScaleY = BMP.Height/2
DIM Timer1 AS QTIMER
Timer1.Interval = 1
Timer1.OnTimer = Timer1OnTimer
CREATE Form AS QFORM
CREATE Canvas AS QCANVAS
OnPaint = CanvasOnPaint
END CREATE
Center
CAPTION = "Rotating Logo"
SHOWMODAL
END CREATE
SUB Timer1OnTimer
DIM X AS INTEGER, Y AS INTEGER
DIM C1 AS DOUBLE, S1 AS DOUBLE, S2 AS DOUBLE, C2 AS DOUBLE
DIM T1 AS DOUBLE, T2 AS DOUBLE
OffBMP.FillRect(0,0,OffBMP.Width,OffBMP.Height,0)
C1 = COS(DEGREE*PI/180)
S1 = -SIN(DEGREE*PI/180)
S2 = -S1
C2 = C1
T1 = -ScaleX*COS(DEGREE*PI/180)+ScaleY*SIN(DEGREE*PI/180)+ScaleX
T2 = -ScaleX*SIN(DEGREE*PI/180)-ScaleY*COS(DEGREE*PI/180)+ScaleY
FOR Y = 0 TO BMP.Height
FOR X = 0 TO BMP.Width
IF BMP.Pixel(X,Y) <> 0 THEN
OffBMP.Pixel(20+X*C1+Y*S1+T1, 40+X*S2+Y*C2+T2) = BMP.Pixel(X,Y)
OffBMP.Pixel(20+X*C1+Y*S1+T1+1, 40+X*S2+Y*C2+T2) = BMP.Pixel(X,Y)
END IF
NEXT
NEXT
CALL CanvasOnPaint
Timer1.Interval = 1
DEGREE -= 10
END SUB
SUB CanvasOnPaint
Canvas.Draw(0, 0, OffBMP.BMP)
END SUB
|