From a1893a44d020dc3af7eea8d679312b32dd04ad77 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 14 May 2022 12:14:41 -0700 Subject: [PATCH] Devine's suggestion to try to live with just freehand https://merveilles.town/@neauoire/108301005736317873 Drawbacks: Smoothing eliminates high-frequency noise but not low-frequency bumps. Making a drawing end at the start point is very challenging. Still perhaps a useful addition to the toolbox for now. I'm going to need a cambrian explosion of tools in the toolbox for a while before I prune. --- main.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.lua b/main.lua index b2278d4..5f415e4 100644 --- a/main.lua +++ b/main.lua @@ -197,6 +197,11 @@ function keychord_pressed(chord) if drawing then convert_horvert(drawing,i,shape) end + elseif chord == 'C-s' then + local drawing,i,shape = select_shape_at_mouse() + if drawing then + smoothen(shape) + end end end @@ -235,5 +240,17 @@ function convert_horvert(drawing, i, shape) end end +function smoothen(shape) + for _=1,7 do + for i=2,#shape-1 do + local a = shape[i-1] + local b = shape[i] + local c = shape[i+1] + b.x = (a.x + b.x + c.x)/3 + b.y = (a.y + b.y + c.y)/3 + end + end +end + function love.keyreleased(key, scancode) end