Line Plotter by Mark Garrett17th Feb 2006 9:48
|
---|
Summary draws a dot-line from one screen coordinate to the next. Line plotter simply takes the largest span between 2 coordinates (let's say 'y' is the largest span between 2 coordinates) Description A way of drawing lines between 2 coordinates on the screen without using the 'line' command and doing it with dots only... Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: lineplot Rem Created: 17.2.2006 6:35:36 Rem ***** Main Source File ***** Rem Project: MouseArrowLineDrawer Rem Created: 31.7.2005 11:37:11 set display mode 1024,768,16 ink rgb(24,165,183),0 set cursor 10,10: print "press left mouse button" wait 1 mxsa = 0: mysa = 0 sync on: sync rate 0 do mx = mousex(): my = mousey() if mouseclick() = 1 then dotline(mxsa,mysa,mx,my):mxsa = mx: mysa = my rem sync loop rem suspend for key function dotline(x1 as integer, y1 as integer,x2 as integer,y2 as integer) x1# = x1: y1# = y1:x2# = x2: y2# = y2 if x1#> x2# then xspan# = (x1# - x2#): goto getyspan xspan# = (x2# - x1#) getyspan: if y1#> y2# then yspan# = (y1# - y2#): goto whichspanbiggest yspan# = (y2# - y1#) whichspanbiggest: if xspan# > yspan# then goto dox doy: if y1# > y2# then y1# = y2: y2# = y1: x1# = x2: x2# = x1 addx# = (xspan# / yspan#) if x1# > x2# then addx# = (0 - addx#) doy1: dot x1#,y1# inc y1#: x1# = (x1# + addx#): if y1# >= y2# then goto done goto doy1 `----------------------------------------------------------------------------- dox: if x1# > x2# then x1# = x2: x2# = x1: y1# = y2: y2# = y1 addy# = (yspan# / xspan#) if y1# > y2# then addy# = (0 - addy#) dox1: dot x1#,y1# inc x1#: y1# = (y1# + addy#): if x1# >= x2# then goto done goto dox1 done: sync endfunction |