new mode: circle arc
[?]
May 15, 2022, 5:24 AM
ZOOY3ME4BUD6RLWCKZFA62JNN4BMPOXH24HGTFWPWEKDECOXMFUACDependencies
- [2]
FMQ74DP3new mode: circle - [*]
OTIBCAUJlove2d scaffold - [*]
JCSLDGAHbeginnings of support for multiple shapes - [*]
NL5J7Z5Hnew mode: polygon - [*]
6LJZN727handle chords - [*]
H7OEU6WPexperimental approach to combining keyboard and mouse while drawing
Change contents
- edit in main.lua at line 185
elseif lines.current.pending.mode == 'arc' thenlocal mx,my = coord(x-16), coord(y-lines.current.y)if mx >= 0 and mx < 256 and my >= 0 and my < lines.current.h thenlocal center = lines.current.points[lines.current.pending.center]lines.current.pending.end_angle = angle_with_hint(center.x,center.y, mx,my, lines.current.pending.end_angle)table.insert(lines.current.shapes, lines.current.pending)end - edit in main.lua at line 266
elseif shape.mode == 'arc' thenlocal center = drawing.points[shape.center]love.graphics.arc('line', 'open', pixels(center.x)+left,pixels(center.y)+top, pixels(shape.radius), shape.start_angle, shape.end_angle, 360)elseprint(shape.mode)assert(false) - edit in main.lua at line 316
elseif shape.mode == 'arc' thenlocal center = drawing.points[shape.center]local mx,my = coord(love.mouse.getX()-16), coord(love.mouse.getY()-drawing.y)if mx < 0 or mx >= 256 or my < 0 or my >= drawing.h thenreturnendshape.end_angle = angle_with_hint(center.x,center.y, mx,my, shape.end_angle)local cx,cy = pixels(center.x)+left, pixels(center.y)+toplove.graphics.arc('line', 'open', cx,cy, pixels(shape.radius), shape.start_angle, shape.end_angle, 360) - edit in main.lua at line 340
elseif shape.mode == 'arc' thenlocal center = drawing.points[shape.center]local dist = math.dist(center.x,center.y, x,y)if dist < shape.radius*0.95 or dist > shape.radius*1.05 thenreturn falseendreturn angle_between(center.x,center.y, x,y, shape.start_angle,shape.end_angle) - edit in main.lua at line 409
function angle_between(x1,y1, x2,y2, s,e)local angle = math.angle(x1,y1, x2,y2)--? print(s,e, angle-math.pi*2, angle, angle+math.pi*2)if s > e thens,e = e,send-- I'm not sure this is right or ideal..angle = angle-math.pi*2if s <= angle and angle <= e thenreturn trueendangle = angle+math.pi*2if s <= angle and angle <= e thenreturn trueendangle = angle+math.pi*2return s <= angle and angle <= eend - edit in main.lua at line 463[2.1410][8.141]
elseif love.mouse.isDown('1') and chord == 'a' and current_mode == 'circle' thenlocal drawing = current_drawing()drawing.pending.mode = 'arc'local mx,my = coord(love.mouse.getX()-16), coord(love.mouse.getY()-drawing.y)local j = insert_point(drawing.points, mx,my)local center = drawing.points[drawing.pending.center]drawing.pending.radius = math.dist(center.x,center.y, mx,my)drawing.pending.start_angle = math.angle(center.x,center.y, mx,my) - edit in main.lua at line 594
endfunction angle_with_hint(x1, y1, x2, y2, hint)local result = math.angle(x1,y1, x2,y2)if hint then-- Smooth the discontinuity where angle goes from positive to negative.-- The hint is a memory of which way we drew it last time.while result > hint+math.pi/10 doresult = result-math.pi*2endwhile result < hint-math.pi/10 doresult = result+math.pi*2endendreturn resultend-- result is from -π/2 to 3π/2, approximately adding math.atan2 from Lua 5.3-- (LÖVE is Lua 5.1)function math.angle(x1,y1, x2,y2)local result = math.atan((y2-y1)/(x2-x1))if x2 < x1 thenresult = result+math.piendreturn result