diff --git a/pixler.bas b/pixler.bas index 716be28..6b2eec6 100644 --- a/pixler.bas +++ b/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) dim osource as long dim odest as long + if state.isdrawing then osource=_source 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 _dest layers(1).ihandle 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 _dest layers(2).ihandle end if + thickline sx,sy,ex,ey,col _source osource _dest odest @@ -701,7 +725,7 @@ sub do.floodfill(x as long,y as long,col as long) if mouseclicked or rmouseclicked then _source layers(1).ihandle _dest layers(1).ihandle - + ' Check if either Left Shift (100303) or Right Shift (100304) is held down if _keydown(100303) or _keydown(100304) then ' 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 addcommand"floodfill ("+tst(x)+","+tst(y)+","+hex$(col)+")" end if - + state.isdrawing=0 _source osource _dest odest