? Rotate graphics 90 degrees ● SmileBASIC Source

Sign In

*Usernames are case-sensitive
Forgot my password
Creep into the Halloween / Horror Programming Contest (Deadline Extended)

Rotate graphics 90 degrees

This is 20 times faster than the routine used in the built in paint tool! DEF R90 X%,Y%,HEIGHT% DIM SEG%[HEIGHT%-1],BACK%[HEIGHT%-1],TEMP%[HEIGHT%-1] VAR START% FOR START%=0 TO (HEIGHT%>>1)-1 VAR EDGE%=HEIGHT%-START%-1 VAR SIZE%=EDGE%-START% VAR AFTER%=START%+1 'save top, reversed GSAVE X%+START%,Y%+AFTER%,1,SIZE%,BACK%,1 RSORT 0,SIZE%,TEMP%,BACK% 'copy left to top GSAVE X%+AFTER%,Y%+EDGE% ,SIZE%,1,SEG% ,1 GLOAD X%+START%,Y%+AFTER%,1,SIZE%,SEG% ,1,1 'copy bottom to left, reversed GSAVE X%+EDGE% ,Y%+START%,1,SIZE%,SEG% ,1 RSORT 0,SIZE%,TEMP%,SEG% GLOAD X%+AFTER%,Y%+EDGE% ,SIZE%,1,SEG% ,1,1 'copy right to bottom GSAVE X%+START%,Y%+START%,SIZE%,1,SEG% ,1 GLOAD X%+EDGE% ,Y%+START%,1,SIZE%,SEG% ,1,1 'load right GLOAD X%+START%,Y%+START%,SIZE%,1,BACK%,1,1 NEXT END OPTION DEFINT DEF R90 X,Y,W DIM A[W-1],B[W-1],TEMP[W-1] VAR I FOR I=0 TO (W>>1)-1 VAR E=W-I-1 VAR L=E-I VAR P=I+1 GSAVE X+I,Y+P,1,L,B,1 RSORT 0,L,TEMP,B GSAVE X+P,Y+E,L,1,A,1 GLOAD X+I,Y+P,1,L,A,1,1 GSAVE X+E,Y+I,1,L,A,1 RSORT 0,L,TEMP,A GLOAD X+P,Y+E,L,1,A,1,1 GSAVE X+I,Y+I,L,1,A,1 GLOAD X+E,Y+I,1,L,A,1,1 GLOAD X+I,Y+I,L,1,B,1,1 NEXT END
2 votes
  • rotate
  • 90
  • graphics
  • function
1 Comment(s) Simeon Simeon Scholar Received for knowing a great deal about programming topics Achievements Amazing Page Hidden Achievements Drawing I like to draw! Hobbies Wow that's an interesting approach