Simple tweak: allow single line in lines

This commit is contained in:
백현웅 2025-01-03 20:54:41 +09:00
parent 3179442942
commit 00601ed4a9
2 changed files with 29 additions and 21 deletions

View file

@ -8,7 +8,7 @@ local edge_data = {
y = 10, y = 10,
width = 80, width = 80,
height = 10, height = 10,
lines = {{'fill', {0, 10, 80, 10, 40, 0}}}, lines = {'fill', {0, 10, 80, 10, 40, 0}},
}, },
down = { down = {
@ -16,7 +16,7 @@ local edge_data = {
y = 220, y = 220,
width = 80, width = 80,
height = 10, height = 10,
lines = {{'fill', {0, 0, 80, 0, 40, 10}}}, lines = {'fill', {0, 0, 80, 0, 40, 10}},
}, },
left = { left = {
@ -24,7 +24,7 @@ local edge_data = {
y = 80, y = 80,
width = 10, width = 10,
height = 80, height = 80,
lines = {{'fill', {10, 0, 10, 80, 0, 40}}}, lines = {'fill', {10, 0, 10, 80, 0, 40}},
}, },
right = { right = {
@ -32,7 +32,7 @@ local edge_data = {
y = 80, y = 80,
width = 10, width = 10,
height = 80, height = 80,
lines = {{'fill', {0, 0, 0, 80, 10, 40}}}, lines = {'fill', {0, 0, 0, 80, 10, 40}},
} }
} }

View file

@ -27,12 +27,7 @@ function m:setpos(x, y)
self.y = y self.y = y
end end
function m:draw() local function draw_line(l)
love.graphics.push('all')
love.graphics.translate(self.x, self.y)
love.graphics.setLineWidth(3)
for _, l in ipairs(self.lines) do
local mode = l[1] local mode = l[1]
local segs = l[2] local segs = l[2]
@ -52,6 +47,19 @@ function m:draw()
end end
end end
function m:draw()
love.graphics.push('all')
love.graphics.translate(self.x, self.y)
love.graphics.setLineWidth(3)
if type(self.lines[1]) == 'string' then
draw_line(self.lines)
else
for _, l in ipairs(self.lines) do
draw_line(l)
end
end
love.graphics.pop() love.graphics.pop()
end end