mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
more testing, thinner debug lines
This commit is contained in:
parent
1cc064068b
commit
fc2d109b2c
2
main.lua
2
main.lua
@ -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)
|
||||
--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)
|
||||
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
|
||||
|
||||
function love.update(dt)
|
||||
|
@ -31,7 +31,7 @@ function box:draw() --NOTE these ifs are probably wrong
|
||||
end
|
||||
|
||||
function box:debugDraw()
|
||||
lg.setLineWidth(1)
|
||||
lg.setLineWidth(0.5)
|
||||
lg.setColor(0, 0, 0, 100)
|
||||
lg.rectangle("fill", self.x, self.y, self.w, self.h)
|
||||
lg.setColor(0, 0, 200, 200)
|
||||
|
@ -19,7 +19,7 @@ function element:initialize(pop, parent)
|
||||
end
|
||||
|
||||
function element:debugDraw()
|
||||
lg.setLineWidth(1)
|
||||
lg.setLineWidth(0.5)
|
||||
lg.setColor(0, 0, 0, 100)
|
||||
lg.rectangle("fill", self.x, self.y, self.w, self.h)
|
||||
lg.setColor(0, 200, 0, 200)
|
||||
|
@ -23,7 +23,7 @@ function text:draw()
|
||||
end
|
||||
|
||||
function text:debugDraw()
|
||||
lg.setLineWidth(1)
|
||||
lg.setLineWidth(0.5)
|
||||
lg.setColor(0, 0, 0, 100)
|
||||
lg.rectangle("fill", self.x, self.y, self.w, self.h)
|
||||
lg.setColor(200, 0, 0, 200)
|
||||
@ -34,7 +34,7 @@ end
|
||||
|
||||
function text:setSize()
|
||||
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
|
||||
self.x = self.x - (w - self.w)/2
|
||||
|
Loading…
Reference in New Issue
Block a user