more testing, thinner debug lines

This commit is contained in:
Fox 2016-01-25 19:02:17 -08:00
parent 1cc064068b
commit fc2d109b2c
4 changed files with 6 additions and 4 deletions

View File

@ -10,6 +10,8 @@ function love.load()
pop.text(nil, "Press \"s\" to show objects for visual testing/demo.\nPress \"t\" to run tests.\nPress \"d\" to toggle debug draw."):move(2, 2) pop.text(nil, "Press \"s\" to show objects for visual testing/demo.\nPress \"t\" to run tests.\nPress \"d\" to toggle debug draw."):move(2, 2)
--TODO correct the fact that the size is wrong here! (height doesn't take into account \n) --TODO correct the fact that the size is wrong here! (height doesn't take into account \n)
--NOTE width? Is width calculated correctly when \n's exist? TEST THIS (also test tabs) --NOTE width? Is width calculated correctly when \n's exist? TEST THIS (also test tabs)
pop.text(nil, "This is a test\ncollection of strings to see how width is determined.\nLooks like it takes width of widest line!"):move(30, 120)
pop.element():align("right", "bottom"):setSize(25, 25):move(-5, -5)
end end
function love.update(dt) function love.update(dt)

View File

@ -31,7 +31,7 @@ function box:draw() --NOTE these ifs are probably wrong
end end
function box:debugDraw() function box:debugDraw()
lg.setLineWidth(1) lg.setLineWidth(0.5)
lg.setColor(0, 0, 0, 100) lg.setColor(0, 0, 0, 100)
lg.rectangle("fill", self.x, self.y, self.w, self.h) lg.rectangle("fill", self.x, self.y, self.w, self.h)
lg.setColor(0, 0, 200, 200) lg.setColor(0, 0, 200, 200)

View File

@ -19,7 +19,7 @@ function element:initialize(pop, parent)
end end
function element:debugDraw() function element:debugDraw()
lg.setLineWidth(1) lg.setLineWidth(0.5)
lg.setColor(0, 0, 0, 100) lg.setColor(0, 0, 0, 100)
lg.rectangle("fill", self.x, self.y, self.w, self.h) lg.rectangle("fill", self.x, self.y, self.w, self.h)
lg.setColor(0, 200, 0, 200) lg.setColor(0, 200, 0, 200)

View File

@ -23,7 +23,7 @@ function text:draw()
end end
function text:debugDraw() function text:debugDraw()
lg.setLineWidth(1) lg.setLineWidth(0.5)
lg.setColor(0, 0, 0, 100) lg.setColor(0, 0, 0, 100)
lg.rectangle("fill", self.x, self.y, self.w, self.h) lg.rectangle("fill", self.x, self.y, self.w, self.h)
lg.setColor(200, 0, 0, 200) lg.setColor(200, 0, 0, 200)
@ -34,7 +34,7 @@ end
function text:setSize() function text:setSize()
local w = self.font:getWidth(self.text) local w = self.font:getWidth(self.text)
local h = self.font:getHeight() local h = self.font:getHeight() * (select(2, self.text:gsub("\n", "\n")) + 1)
if self.horizontal == "center" then if self.horizontal == "center" then
self.x = self.x - (w - self.w)/2 self.x = self.x - (w - self.w)/2