shifty straight lines.

This commit is contained in:
visionmercer 2026-05-22 13:10:54 +02:00
commit 4e2d0dd9b1

View file

@ -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