shifty squares

This commit is contained in:
visionmercer 2026-05-22 13:59:15 +02:00
commit 3ff50d22d5

View file

@ -605,9 +605,29 @@ end sub
sub do.box (sx as long,sy as long,ex as long,ey as long,col as long) sub do.box (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
' --- Shift Held: Perfect Square Constraint ---
if _keydown(100303) or _keydown(100304) then
dim dx as long: dx = ex - sx
dim dy as long: dy = ey - sy
' Determine the longest side to use as the square dimensions
dim size as long
if abs(dx) > abs(dy) then size = abs(dx) else size = abs(dy)
' Shift coordinates relative to the direction of the drag
dim signx as long: if dx >= 0 then signx = 1 else signx = -1
dim signy as long: if dy >= 0 then signy = 1 else signy = -1
ex = sx + (size * signx)
ey = sy + (size * signy)
end if
' ---------------------------------------------
if mouseclicked or rmouseclicked then if mouseclicked or rmouseclicked then
_dest layers(1).ihandle _dest layers(1).ihandle
addcommand"box ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")" addcommand"box ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")"
@ -624,9 +644,29 @@ end sub
sub do.fbox (sx as long,sy as long,ex as long,ey as long,col as long) sub do.fbox (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
' --- Shift Held: Perfect Square Constraint ---
if _keydown(100303) or _keydown(100304) then
dim dx as long: dx = ex - sx
dim dy as long: dy = ey - sy
' Determine the longest side to use as the square dimensions
dim size as long
if abs(dx) > abs(dy) then size = abs(dx) else size = abs(dy)
' Shift coordinates relative to the direction of the drag
dim signx as long: if dx >= 0 then signx = 1 else signx = -1
dim signy as long: if dy >= 0 then signy = 1 else signy = -1
ex = sx + (size * signx)
ey = sy + (size * signy)
end if
' ---------------------------------------------
if mouseclicked or rmouseclicked then if mouseclicked or rmouseclicked then
_dest layers(1).ihandle _dest layers(1).ihandle
addcommand"fbox ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")" addcommand"fbox ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")"