revert: back to freehand
[?]
May 14, 2022, 6:59 PM
KCIM5UTVV4KIL7SNRZFOW6FUQHGWAPOGQO4QTVNIWWBWMVG6GYNQCDependencies
- [2]
O2UFJ6G3switch from freehand to just straight lines - [3]
EFMLTMZGbugfix: restrict strokes to the drawing they started in - [4]
G77XIN7Mselecting a stroke - [5]
3XD6M3CFrefactor - [6]
KVHUFUFVreorg - [7]
Z2CJVAPVlighter border for figures - [8]
MNWHXPBLmore lightweight; select just the stroke at the mouse - [9]
T76KKDWZturn strokes into horizontal and vertical lines - [10]
WAZVXUV2simplest possible way to straighten strokes - [11]
JVRL5TWLstore device-independent coordinates inside drawings - [12]
OTIBCAUJlove2d scaffold - [13]
U76D4P36fix a typo - [14]
XX7G2FFJintermingle freehand line drawings with text - [*]
6LJZN727handle chords - [*]
D2GCFTTTclean up repl functionality
Change contents
- replacement in main.lua at line 60
if on_line(mx,my, shape) thenif on_freehand(mx,my, shape) then - replacement in main.lua at line 65
love.graphics.line(pixels(shape.x1)+12,pixels(shape.y1)+line.y, pixels(shape.x2)+12,pixels(shape.y2)+line.y)prev = nilfor _,point in ipairs(shape) doif prev thenlove.graphics.line(pixels(prev.x)+12,pixels(prev.y)+line.y, pixels(point.x)+12,pixels(point.y)+line.y)endprev = pointend - replacement in main.lua at line 73
if line.pending.x1 thenlove.graphics.line(pixels(line.pending.x1)+12,pixels(line.pending.y1)+line.y, love.mouse.getX(),love.mouse.getY())prev = nilfor _,point in ipairs(line.pending) doif prev thenlove.graphics.line(pixels(prev.x)+12,pixels(prev.y)+line.y, pixels(point.x)+12,pixels(point.y)+line.y)endprev = point - edit in main.lua at line 100
table.insert(drawing.pending, {x=coord(love.mouse.getX()-12), y=coord(love.mouse.getY()-drawing.y)}) - edit in main.lua at line 110
endfunction love.mousereleased(x,y, button)if lines.current thenif lines.current.pending thenlines.current.pending.x2 = coord(x-12)lines.current.pending.y2 = coord(y-lines.current.y)table.insert(lines.current.shapes, lines.current.pending)lines.current.pending = {}lines.current = nilendend - edit in main.lua at line 117
drawing.pending = {x1=coord(x-12), y1=coord(y-drawing.y)} - edit in main.lua at line 158
function love.mousereleased(x,y, button)if lines.current thenif lines.current.pending thentable.insert(lines.current.shapes, lines.current.pending)lines.current.pending = {}lines.current = nilendendend - edit in main.lua at line 190[17.1135][3.11]
elseif chord == 'C-l' thenlocal drawing,i,shape = select_shape_at_mouse()if drawing thenconvert_line(drawing,i,shape)end - replacement in main.lua at line 210
if on_line(mx,my, shape) thenif on_freehand(mx,my, shape) then - edit in main.lua at line 217
endfunction convert_line(drawing, i, shape)-- Perhaps we should do a more sophisticated "simple linear regression"-- here:-- https://en.wikipedia.org/wiki/Linear_regression#Simple_and_multiple_linear_regression-- But this works well enough for close-to-linear strokes.drawing.shapes[i] = {shape[1], shape[#shape]} - replacement in main.lua at line 229
if math.abs(shape.x1-shape.x2) > math.abs(shape.y1-shape.y2) thenshape.y2 = shape.y1local x1,y1 = shape[1].x, shape[1].ylocal x2,y2 = shape[#shape].x, shape[#shape].yif math.abs(x1-x2) > math.abs(y1-y2) thendrawing.shapes[i] = {{x=x1, y=y1}, {x=x2, y=y1}} - replacement in main.lua at line 234
shape.x2 = shape.x1drawing.shapes[i] = {{x=x1, y=y1}, {x=x1, y=y2}}