' ROTATE_2.LST
' Rotate graphic by any degree
' ----------------------------
' Create graphic
DEFFILL 1,3,8
PBOX 1,1,208,48
DEFTEXT 1,0,0,26
TEXT 13,36,"GFA - Basic"
'
' Offset from top left
x%=1
y%=1
' Width and height
w%=208
h%=48
' Rotation angle in degrees (trig.)
ang%=45
rad=ang%*PI/180
'
' Save graphic
GET x%,y%,x%+w%-1,y%+h%-1,s$
s%=VARPTR(s$)+6
'
' Byte length of graphic in GET format (made up to word)
xb%=((w%+15) DIV 16)*2
'
' Destination is always the screen
'
t=TIMER
'
' Temporary address, always
' that of bottom left screen corner
dh%=XBIOS(2)+80*399
'
' Start values of destination coordinates:
s=SIN(rad)
c=COS(rad)
' Step width
step=2/3
' display rotated graphic in centre
xm%=320-((h%-1)*s+(w%-1)*c)/2+0.5
ym%=200-((h%-1)*c-(w%-1)*s)/2+0.5
' Hide mouse (faster)
HIDEM
' Set strip at bottom of screen, calculate polar coordinates
' Display rotation point on screen
FOR y0=0 TO h%-1+step STEP step
  BMOVE s%+INT(y0)*xb%,dh%,xb%
  yh=ym%+y0*c+0.5
  xh=xm%+y0*s+0.5
  FOR x0=0 TO w%-1+step STEP step
    yk%=yh-x0*s
    COLOR POINT(x0,399)
    IF yk%<399
      xk%=xh+x0*c
      PLOT xk%,yk%
    ENDIF
  NEXT x0
NEXT y0
'
' erase bottom screen row
COLOR 0
LINE 0,399,639,399
COLOR 1
SHOWM
'
tt=(TIMER-t)/200
t$=STR$(tt)
'
ALERT 1,"Rotating graphic |in GFA Basic takes|"+t$+" seconds.",1," OK ",d%
'
EDIT
