Shifty circles

This commit is contained in:
visionmercer 2026-05-22 13:56:25 +02:00
commit df717cb9b0

View file

@ -450,9 +450,11 @@ sub canvas
case 2
do.line state.startx,state.starty,canx,cany,drawcol
case 3
do.circle state.startx,state.starty,sqr((canx-state.startx)^2+(cany-state.starty)^2),drawcol
' Pass current mouse canvas coordinates directly
do.circle state.startx,state.starty,canx,cany,drawcol
case 4
do.fcircle state.startx,state.starty,sqr((canx-state.startx)^2+(cany-state.starty)^2),drawcol
' Pass current mouse canvas coordinates directly
do.fcircle state.startx,state.starty,canx,cany,drawcol
case 5
do.box state.startx,state.starty,canx,cany,drawcol
case 6
@ -492,26 +494,19 @@ sub do.line(sx as long,sy as long,ex as long,ey as long,col as long)
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 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
dim snappedangle as single:snappedangle=snappeddegrees*(_pi/180.0)
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
@ -527,12 +522,33 @@ sub do.line(sx as long,sy as long,ex as long,ey as long,col as long)
end if
end sub
sub do.circle (x as long,y as long,r as long,col as long)
sub do.circle (sx as long,sy as long,ex as long,ey as long,col as long)
dim osource as long
dim odest as long
dim x as long,y as long,r as long
if state.isdrawing then
osource=_source
odest=_dest
if _keydown(100303) or _keydown(100304) then
' --- Shift Held: Locked Edge Diameter Mode ---
' Calculate the full distance from the start click to the mouse pointer
dim diameter as single
diameter = sqr((ex - sx) ^ 2 + (ey - sy) ^ 2)
r = _round(diameter / 2)
' The center is the exact midpoint between the click and the cursor
x = _round((sx + ex) / 2)
y = _round((sy + ey) / 2)
else
' --- No Shift: Default Center-Radius Mode ---
x = sx
y = sy
r = _round(sqr((ex - sx) ^ 2 + (ey - sy) ^ 2))
end if
if mouseclicked or rmouseclicked then
_dest layers(1).ihandle
addcommand"circle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
@ -546,12 +562,33 @@ sub do.circle (x as long,y as long,r as long,col as long)
end if
end sub
sub do.fcircle (x as long,y as long,r as long,col as long)
sub do.fcircle (sx as long,sy as long,ex as long,ey as long,col as long)
dim osource as long
dim odest as long
dim x as long,y as long,r as long
if state.isdrawing then
osource=_source
odest=_dest
if _keydown(100303) or _keydown(100304) then
' --- Shift Held: Locked Edge Diameter Mode ---
' Calculate the full distance from the start click to the mouse pointer
dim diameter as single
diameter = sqr((ex - sx) ^ 2 + (ey - sy) ^ 2)
r = _round(diameter / 2)
' The center is the exact midpoint between the click and the cursor
x = _round((sx + ex) / 2)
y = _round((sy + ey) / 2)
else
' --- No Shift: Default Center-Radius Mode ---
x = sx
y = sy
r = _round(sqr((ex - sx) ^ 2 + (ey - sy) ^ 2))
end if
if mouseclicked or rmouseclicked then
_dest layers(1).ihandle
addcommand"fcircle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"