add a level of indirection to vertices of shapes
[?]
May 14, 2022, 11:00 PM
IFGAJAF7UWM236QV4NWP2C67TJPQGXNBC2RTZCOWPJUJYYC2MMXACDependencies
- [2]
4NDYV4WDfix 2 bugs in line selection - [3]
GP56QHRHbugfix - [4]
ZD63LJ2Tbugfix: keep the click to create a new drawing from creating a new shape in the drawing - [5]
6F6DF5T3. - [6]
O2UFJ6G3switch from freehand to just straight lines - [7]
D2GCFTTTclean up repl functionality - [8]
R3WSFYGYspacing - [9]
G77XIN7Mselecting a stroke - [10]
Z2CJVAPVlighter border for figures - [11]
T76KKDWZturn strokes into horizontal and vertical lines - [12]
H7OEU6WPexperimental approach to combining keyboard and mouse while drawing - [13]
6LJZN727handle chords - [14]
EFMLTMZGbugfix: restrict strokes to the drawing they started in - [15]
OTIBCAUJlove2d scaffold - [16]
MNWHXPBLmore lightweight; select just the stroke at the mouse - [17]
3XD6M3CFrefactor - [18]
JVRL5TWLstore device-independent coordinates inside drawings - [19]
XX7G2FFJintermingle freehand line drawings with text - [20]
JCSLDGAHbeginnings of support for multiple shapes - [21]
KCIM5UTVrevert: back to freehand
Change contents
- replacement in main.lua at line 78
table.insert(lines, i, {y=y, h=256/2, shapes={}, pending={}})table.insert(lines, i, {y=y, h=256/2, points={}, shapes={}, pending={}}) - replacement in main.lua at line 90
if on_shape(mx,my, shape) thenif on_shape(mx,my, line, shape) then - replacement in main.lua at line 95
draw_shape(16,line.y, shape)draw_shape(16,line.y, line, shape)endfor _,p in ipairs(line.points) doif p.x == mx and p.y == my thenlove.graphics.setColor(1,0,0)elselove.graphics.setColor(0,0,0)endlove.graphics.circle('line', pixels(p.x)+16,pixels(p.y)+line.y, 4) - replacement in main.lua at line 105
draw_pending_shape(16,line.y, line.pending)draw_pending_shape(16,line.y, line) - replacement in main.lua at line 146
lines.current.pending.x2 = coord(x-16)lines.current.pending.y2 = coord(y-lines.current.y)local j = insert_point(lines.current.points, coord(x-16), coord(y-lines.current.y))lines.current.pending.p2 = j - replacement in main.lua at line 164
drawing.pending = {mode='line', x1=coord(x-16), y1=coord(y-drawing.y)}local j = insert_point(drawing.points, coord(x-16), coord(y-drawing.y))drawing.pending = {mode='line', p1=j} - replacement in main.lua at line 173
function draw_shape(left,top, shape)function insert_point(points, x,y)for i,point in ipairs(points) doif point.x == x and point.y == y thenreturn iendendtable.insert(points, {x=x, y=y})return #pointsendfunction draw_shape(left,top, drawing, shape) - replacement in main.lua at line 193
love.graphics.line(pixels(shape.x1)+left,pixels(shape.y1)+top, pixels(shape.x2)+left,pixels(shape.y2)+top)local p1 = drawing.points[shape.p1]local p2 = drawing.points[shape.p2]love.graphics.line(pixels(p1.x)+left,pixels(p1.y)+top, pixels(p2.x)+left,pixels(p2.y)+top) - replacement in main.lua at line 199
function draw_pending_shape(left,top, shape)function draw_pending_shape(left,top, drawing)local shape = drawing.pending - replacement in main.lua at line 202
draw_shape(left,top, shape)draw_shape(left,top, drawing, shape) - replacement in main.lua at line 204
love.graphics.line(pixels(shape.x1)+left,pixels(shape.y1)+top, love.mouse.getX(),love.mouse.getY())local p1 = drawing.points[shape.p1]love.graphics.line(pixels(p1.x)+left,pixels(p1.y)+top, love.mouse.getX(),love.mouse.getY()) - replacement in main.lua at line 209
function on_shape(x,y, shape)function on_shape(x,y, drawing, shape) - replacement in main.lua at line 211
return on_freehand(x,y, shape)return on_freehand(x,y, drawing, shape) - replacement in main.lua at line 213
return on_line(x,y, shape)return on_line(x,y, drawing, shape) - replacement in main.lua at line 219
function on_freehand(x,y, shape)function on_freehand(x,y, drawing, shape) - replacement in main.lua at line 223
if on_line(x,y, {x1=prev.x,y1=prev.y, x2=p.x,y2=p.y}) thenif on_line(x,y, drawing, {p1=prev, p2=p}) then - replacement in main.lua at line 232
function on_line(x,y, shape)if shape.x1 == shape.x2 thenif math.abs(shape.x1-x) > 5 thenfunction on_line(x,y, drawing, shape)local p1,p2if type(shape.p1) == 'number' thenp1 = drawing.points[shape.p1]p2 = drawing.points[shape.p2]elsep1 = shape.p1p2 = shape.p2endif p1.x == p2.x thenif math.abs(p1.x-x) > 5 then - replacement in main.lua at line 245
local y1,y2 = shape.y1,shape.y2local y1,y2 = p1.y,p2.y - replacement in main.lua at line 252
local m = (shape.y2 - shape.y1) / (shape.x2 - shape.x1)local yp = shape.y1 + m*(x-shape.x1)local m = (p2.y - p1.y) / (p2.x - p1.x)local yp = p1.y + m*(x-p1.x) - replacement in main.lua at line 258
local k = (x-shape.x1) / (shape.x2-shape.x1)local k = (x-p1.x) / (p2.x-p1.x) - replacement in main.lua at line 293
drawing.pending.x1 = drawing.pending.points[1].xdrawing.pending.y1 = drawing.pending.points[1].ydrawing.pending.p1 = insert_point(drawing.points, drawing.pending.points[1].x, drawing.pending.points[1].y) - replacement in main.lua at line 298
convert_line(shape)convert_line(drawing, shape) - replacement in main.lua at line 303
convert_horvert(shape)convert_horvert(drawing, shape) - replacement in main.lua at line 353
function convert_line(shape)function convert_line(drawing, shape) - replacement in main.lua at line 360
shape.x1 = shape.points[1].xshape.y1 = shape.points[1].yshape.x2 = shape.points[#shape.points].xshape.y2 = shape.points[#shape.points].yshape.p1 = insert_point(drawing.points, shape.points[1].x, shape.points[1].y)local n = #shape.pointsshape.p2 = insert_point(drawing.points, shape.points[n].x, shape.points[n].y) - replacement in main.lua at line 366
function convert_horvert(shape)function convert_horvert(drawing, shape) - replacement in main.lua at line 371
if math.abs(shape.x1-shape.x2) > math.abs(shape.y1-shape.y2) thenshape.y2 = shape.y1local p1 = drawing.points[shape.p1]local p2 = drawing.points[shape.p2]if math.abs(p1.x-p2.x) > math.abs(p1.y-p2.y) thenp2.y = p1.y - replacement in main.lua at line 376
shape.x2 = shape.x1p2.x = p1.x