shifty straight lines.
This commit is contained in:
parent
bbdb7a3033
commit
4e2d0dd9b1
1 changed files with 26 additions and 2 deletions
28
pixler.bas
28
pixler.bas
|
|
@ -487,9 +487,32 @@ end sub
|
||||||
sub do.line(sx as long,sy as long,ex as long,ey as long,col as long)
|
sub do.line(sx as long,sy as long,ex as long,ey as long,col as long)
|
||||||
dim osource as long
|
dim osource as long
|
||||||
dim odest as long
|
dim odest as long
|
||||||
|
|
||||||
if state.isdrawing then
|
if state.isdrawing then
|
||||||
osource=_source
|
osource=_source
|
||||||
odest=_dest
|
odest=_dest
|
||||||
|
|
||||||
|
' --- 45-Degree Angle Snapping Logic ---
|
||||||
|
if _keydown(100303) or _keydown(100304) then
|
||||||
|
dim dx as single:dx=ex-sx
|
||||||
|
dim dy as single:dy=ey-sy
|
||||||
|
|
||||||
|
if dx<>0 or dy<>0 then
|
||||||
|
dim linelen as single:linelen=sqr(dx*dx+dy*dy)
|
||||||
|
dim angle as single:angle=_atan2(dy,dx)
|
||||||
|
|
||||||
|
dim pi as single:pi=3.14159265
|
||||||
|
dim degrees as single:degrees=angle*(180.0/pi)
|
||||||
|
dim snappeddegrees as single:snappeddegrees=int((degrees+22.5)/45.0)*45.0
|
||||||
|
dim snappedangle as single:snappedangle=snappeddegrees*(pi/180.0)
|
||||||
|
|
||||||
|
' FIX: Changed int() to _round() to prevent left/top pixel drifting
|
||||||
|
ex=sx+_round(linelen*cos(snappedangle))
|
||||||
|
ey=sy+_round(linelen*sin(snappedangle))
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
' --------------------------------------
|
||||||
|
|
||||||
if mouseclicked or rmouseclicked then
|
if mouseclicked or rmouseclicked then
|
||||||
_dest layers(1).ihandle
|
_dest layers(1).ihandle
|
||||||
addcommand"line ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")"
|
addcommand"line ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")"
|
||||||
|
|
@ -497,6 +520,7 @@ sub do.line(sx as long,sy as long,ex as long,ey as long,col as long)
|
||||||
else
|
else
|
||||||
_dest layers(2).ihandle
|
_dest layers(2).ihandle
|
||||||
end if
|
end if
|
||||||
|
|
||||||
thickline sx,sy,ex,ey,col
|
thickline sx,sy,ex,ey,col
|
||||||
_source osource
|
_source osource
|
||||||
_dest odest
|
_dest odest
|
||||||
|
|
@ -701,7 +725,7 @@ sub do.floodfill(x as long,y as long,col as long)
|
||||||
if mouseclicked or rmouseclicked then
|
if mouseclicked or rmouseclicked then
|
||||||
_source layers(1).ihandle
|
_source layers(1).ihandle
|
||||||
_dest layers(1).ihandle
|
_dest layers(1).ihandle
|
||||||
|
|
||||||
' Check if either Left Shift (100303) or Right Shift (100304) is held down
|
' Check if either Left Shift (100303) or Right Shift (100304) is held down
|
||||||
if _keydown(100303) or _keydown(100304) then
|
if _keydown(100303) or _keydown(100304) then
|
||||||
' Fill until it hits the background color as a border
|
' Fill until it hits the background color as a border
|
||||||
|
|
@ -712,7 +736,7 @@ sub do.floodfill(x as long,y as long,col as long)
|
||||||
floodfill x,y,col
|
floodfill x,y,col
|
||||||
addcommand"floodfill ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
addcommand"floodfill ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
||||||
end if
|
end if
|
||||||
|
|
||||||
state.isdrawing=0
|
state.isdrawing=0
|
||||||
_source osource
|
_source osource
|
||||||
_dest odest
|
_dest odest
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue