turn strokes into horizontal and vertical lines

This commit is contained in:
Kartik K. Agaram 2022-05-11 22:33:45 -07:00
parent ccf7ecc502
commit fbba31ff7a
1 changed files with 16 additions and 0 deletions

View File

@ -176,6 +176,11 @@ function keychord_pressed(chord)
if drawing then
convert_line(drawing,i,shape)
end
elseif chord == 'C-m' then
local drawing,i,shape = select_shape_at_mouse()
if drawing then
convert_horvert(drawing,i,shape)
end
end
end
@ -202,5 +207,16 @@ function convert_line(drawing, i, shape)
drawing.shapes[i] = {shape[1], shape[#shape]}
end
-- turn a stroke into either a horizontal or vertical line
function convert_horvert(drawing, i, shape)
local x1,y1 = shape[1].x, shape[1].y
local x2,y2 = shape[#shape].x, shape[#shape].y
if math.abs(x1-x2) > math.abs(y1-y2) then
drawing.shapes[i] = {{x=x1, y=y1}, {x=x2, y=y1}}
else
drawing.shapes[i] = {{x=x1, y=y1}, {x=x1, y=y2}}
end
end
function love.keyreleased(key, scancode)
end