' ROT_1.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 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
'
t=TIMER
'
' Destination is always the screen
'
' Temporary address, always
' same as bottom left corner of screen
dh%=XBIOS(2)+80*399
'
' display graphic in centre
xm%=320-((h%-1)*SIN(rad)+(w%-1)*COS(rad))/2+0.5
ym%=200-((h%-1)*COS(rad)-(w%-1)*SIN(rad))/2+0.5
' Hide mouse (faster)
HIDEM
' Set strip at screen bottom, calculate polar coordinates
' Display rotation point on screen
FOR y0=0 TO h%-1+2/3 STEP 2/3
  BMOVE s%+INT(y0)*xb%,dh%,xb%
  FOR x0=0 TO w%-1+2/3 STEP 2/3
    yk%=ym%+y0*COS(rad)+0.5-x0*SIN(rad)
    COLOR POINT(x0,399)
    IF yk%<399
      xk%=xm%+y0*SIN(rad)+0.5+x0*COS(rad)
      IF yk%>=0 AND xk%>=0 AND xk%<=639
        PLOT xk%,yk%
      ENDIF
    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
