Almost done drawing lines
This commit is contained in:
parent
74fdcd51f7
commit
abce928481
4 changed files with 159 additions and 7 deletions
26
line.lua
26
line.lua
|
|
@ -38,7 +38,7 @@ function Line:draw()
|
|||
love.graphics.circle( "fill", sx, sy, Config.linePointRadius )
|
||||
local ex, ey = self.endpoint:globalCoords()
|
||||
love.graphics.circle( "fill", ex, ey, Config.linePointRadius )
|
||||
if #self.points == 1 then
|
||||
if #self.points <= 1 then
|
||||
love.graphics.setColor( Color.white )
|
||||
return
|
||||
end
|
||||
|
|
@ -52,3 +52,27 @@ function Line:draw()
|
|||
love.graphics.line( points )
|
||||
love.graphics.setColor( Color.white )
|
||||
end
|
||||
|
||||
-- Clear points
|
||||
function Line:clear()
|
||||
for k, _ in pairs( self.points ) do
|
||||
self.points[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Swap startpoint and endpoint
|
||||
function Line:reverse()
|
||||
local swap = self.startpoint
|
||||
self.startpoint = self.endpoint
|
||||
self.endpoint = swap
|
||||
self:push( self.startpoint )
|
||||
end
|
||||
|
||||
-- Check if line has the exact point
|
||||
function Line:has( point )
|
||||
return tableHas( self.points, point,
|
||||
function( value, innervalue )
|
||||
return innervalue:equals( value )
|
||||
end
|
||||
)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue