LoginLogin

GSCALE

Root / Submissions / [.]

MZ952Created:
Fast scaling of regions of the graphics page. Graphical artifacts are possible with this method due to floating point errors.
OPTION STRICT
OPTION DEFINT
DEF GSCALE X0,Y0,X1,Y1,SCX#,SXY#
 DIM X#:FOR X#=X1+1 TO X0 STEP -1/SCX#
  GCOPY X#,Y0,X#,Y1,(X#-X0)*SCX#+X0,Y0,1
 NEXT X#:DIM DX1=(X1-X0+1)*SCX#+X0
 DIM Y#:FOR Y#=Y1+1 TO Y0 STEP -1/SCY#
  GCOPY X0,Y#,DX1,Y#,X0,(Y#-Y0)*SCY#+Y0,1
 NEXT Y#
END
demo code:
OPTION STRICT
OPTION DEFINT
ACLS
DIM TM,TX,TY
WHILE 1
 TOUCH OUT TM,TX,TY
 IF TM THEN
  GCOPY 4,0,0,64-1,64-1,0,240,1
  GSCALE 0,240,64-1,240+64-1,TX/64,TY/64
  GCOPY 0,240,TX,TY+240,0,0,1
 ENDIF
WEND

No posts yet (will you be the first?)