Shifty circles
This commit is contained in:
parent
4e2d0dd9b1
commit
df717cb9b0
1 changed files with 50 additions and 13 deletions
63
pixler.bas
63
pixler.bas
|
|
@ -450,9 +450,11 @@ sub canvas
|
||||||
case 2
|
case 2
|
||||||
do.line state.startx,state.starty,canx,cany,drawcol
|
do.line state.startx,state.starty,canx,cany,drawcol
|
||||||
case 3
|
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
|
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
|
case 5
|
||||||
do.box state.startx,state.starty,canx,cany,drawcol
|
do.box state.startx,state.starty,canx,cany,drawcol
|
||||||
case 6
|
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
|
osource=_source
|
||||||
odest=_dest
|
odest=_dest
|
||||||
|
|
||||||
' --- 45-Degree Angle Snapping Logic ---
|
|
||||||
if _keydown(100303) or _keydown(100304) then
|
if _keydown(100303) or _keydown(100304) then
|
||||||
dim dx as single:dx=ex-sx
|
dim dx as single:dx=ex-sx
|
||||||
dim dy as single:dy=ey-sy
|
dim dy as single:dy=ey-sy
|
||||||
|
|
||||||
if dx<>0 or dy<>0 then
|
if dx<>0 or dy<>0 then
|
||||||
dim linelen as single:linelen=sqr(dx*dx+dy*dy)
|
dim linelen as single:linelen=sqr(dx*dx+dy*dy)
|
||||||
dim angle as single:angle=_atan2(dy,dx)
|
dim angle as single:angle=_atan2(dy,dx)
|
||||||
|
dim degrees as single:degrees=angle*(180.0/_pi)
|
||||||
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 snappeddegrees as single:snappeddegrees=int((degrees+22.5)/45.0)*45.0
|
||||||
dim snappedangle as single:snappedangle=snappeddegrees*(pi/180.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))
|
ex=sx+_round(linelen*cos(snappedangle))
|
||||||
ey=sy+_round(linelen*sin(snappedangle))
|
ey=sy+_round(linelen*sin(snappedangle))
|
||||||
end if
|
end if
|
||||||
end if
|
end if
|
||||||
' --------------------------------------
|
|
||||||
|
|
||||||
if mouseclicked or rmouseclicked then
|
if mouseclicked or rmouseclicked then
|
||||||
_dest layers(1).ihandle
|
_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 if
|
||||||
end sub
|
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 osource as long
|
||||||
dim odest as long
|
dim odest as long
|
||||||
|
dim x as long,y as long,r as long
|
||||||
|
|
||||||
if state.isdrawing then
|
if state.isdrawing then
|
||||||
osource=_source
|
osource=_source
|
||||||
odest=_dest
|
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
|
if mouseclicked or rmouseclicked then
|
||||||
_dest layers(1).ihandle
|
_dest layers(1).ihandle
|
||||||
addcommand"circle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
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 if
|
||||||
end sub
|
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 osource as long
|
||||||
dim odest as long
|
dim odest as long
|
||||||
|
dim x as long,y as long,r as long
|
||||||
|
|
||||||
if state.isdrawing then
|
if state.isdrawing then
|
||||||
osource=_source
|
osource=_source
|
||||||
odest=_dest
|
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
|
if mouseclicked or rmouseclicked then
|
||||||
_dest layers(1).ihandle
|
_dest layers(1).ihandle
|
||||||
addcommand"fcircle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
addcommand"fcircle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue