diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-05-21 14:03:06 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-05-21 14:03:06 -0700 |
commit | bb9e23a6385675fa073ec187ba84d3fd8636dfc2 (patch) | |
tree | 957d2a6072f4a634e2877ed216a67ffd9a6c522e /drawing.lua | |
parent | 96df1874883e9d9700be394df6bcafdf9e3ad4b7 (diff) | |
download | lines.love-bb9e23a6385675fa073ec187ba84d3fd8636dfc2.tar.gz |
support for naming points
There's still an absence of affordance showing when you're in naming mode.
Diffstat (limited to 'drawing.lua')
-rw-r--r-- | drawing.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drawing.lua b/drawing.lua index 28794a3..611a522 100644 --- a/drawing.lua +++ b/drawing.lua @@ -46,6 +46,10 @@ function Drawing.draw(line) love.graphics.setColor(0,0,0) love.graphics.circle('fill', Drawing.pixels(p.x)+16,Drawing.pixels(p.y)+line.y, 2) end + if p.name then + -- todo: clip + love.graphics.print(p.name, Drawing.pixels(p.x)+16+5,Drawing.pixels(p.y)+line.y+5, 0, Zoom) + end end end love.graphics.setColor(0.75,0.75,0.75) @@ -78,6 +82,7 @@ function Drawing.draw_shape(left,top, drawing, shape) local curr = drawing.points[shape.vertices[1]] love.graphics.line(Drawing.pixels(prev.x)+left,Drawing.pixels(prev.y)+top, Drawing.pixels(curr.x)+left,Drawing.pixels(curr.y)+top) elseif shape.mode == 'circle' then + -- todo: clip local center = drawing.points[shape.center] love.graphics.circle('line', Drawing.pixels(center.x)+left,Drawing.pixels(center.y)+top, Drawing.pixels(shape.radius)) elseif shape.mode == 'arc' then @@ -173,6 +178,8 @@ function Drawing.draw_pending_shape(left,top, drawing) love.graphics.arc('line', 'open', cx,cy, Drawing.pixels(shape.radius), shape.start_angle, shape.end_angle, 360) elseif shape.mode == 'move' then -- nothing pending; changes are immediately committed + elseif shape.mode == 'name' then + -- nothing pending; changes are immediately committed else print(shape.mode) assert(false) @@ -468,6 +475,15 @@ function Drawing.keychord_pressed(chord) drawing.pending = {mode=Current_drawing_mode, target_point=p} Lines.current = drawing end + elseif chord == 'C-n' and not love.mouse.isDown('1') then + local drawing,point_index,p = Drawing.select_point_at_mouse() + if drawing then + Previous_drawing_mode = Current_drawing_mode + Current_drawing_mode = 'name' + p.name = '' + drawing.pending = {mode=Current_drawing_mode, target_point=point_index} + Lines.current = drawing + end elseif chord == 'C-d' and not love.mouse.isDown('1') then local drawing,i,p = Drawing.select_point_at_mouse() if drawing then |