selecting a stroke
[?]
May 12, 2022, 5:01 AM
G77XIN7MLX465AXLXDUJDGEHXXCMR2Q7K25UAMKQERBJGNJPNW6ACDependencies
- [2]
Z2CJVAPVlighter border for figures - [3]
EFMLTMZGbugfix: restrict strokes to the drawing they started in - [4]
QU7NHFOVshow cursor - [5]
IZZVOCLBconfirm that we have access to all of the love API - [6]
XX7G2FFJintermingle freehand line drawings with text - [7]
OTIBCAUJlove2d scaffold - [8]
TRCAEE2Aclip drawings inside the border
Change contents
- edit in main.lua at line 7
mode = '' - edit in main.lua at line 47
love.graphics.setColor(0,0,0) - edit in main.lua at line 48
if shape.selected thenlove.graphics.setColor(1,0,0)elselove.graphics.setColor(0,0,0)end - replacement in main.lua at line 82
if love.mouse.isDown('1') thenif love.mouse.isDown('1') and mode == 'draw' then - edit in main.lua at line 101
mode = 'grab' - edit in main.lua at line 107
for _,shape in ipairs(drawing.shapes) doif on_freehand(x,y, shape) thenshape.selected = truereturnendend - edit in main.lua at line 116
mode = 'draw' - edit in main.lua at line 119
function on_freehand(x,y, shape)local prevfor _,p in ipairs(shape) doif prev thenif on_line(x,y, {x1=prev.x,y1=prev.y, x2=p.x,y2=p.y}) thenreturn trueendendprev = pendreturn falseendfunction on_line(x,y, shape)if shape.x1 == shape.x2 thenlocal y1,y2 = shape.y1,shape.y2if y1 > y2 theny1,y2 = y2,y2endreturn y >= y1 and y <= y2end-- has the right slope and interceptlocal m = (shape.y2 - shape.y1) / (shape.x2 - shape.x1)local yp = shape.y1 + m*(x-shape.x1)if yp < 0.95*y or yp > 1.05*y thenreturn falseend-- between endpointslocal k = (x-shape.x1) / (shape.x2-shape.x1)return k > -0.05 and k < 1.05end