Make time display bigger

This commit is contained in:
Brandon Dyck 2024-04-21 16:44:14 -06:00
parent 42ab042e59
commit 3267fba979

View File

@ -21,12 +21,13 @@ function love.load()
local exitNote = "Press \"Esc\" to exit." local exitNote = "Press \"Esc\" to exit."
local column2Width = love.graphics.getWidth() - column2X - margin local column2Width = love.graphics.getWidth() - column2X - margin
local font = love.graphics.newFont(love.graphics.getHeight() / 20) local textFont = love.graphics.newFont(love.graphics.getHeight() / 20)
local timeFont = love.graphics.newFont(love.graphics.getHeight() / 10)
local _, exitNoteWraps = font:getWrap(exitNote, column2Width) local _, exitNoteWraps = textFont:getWrap(exitNote, column2Width)
local exitNoteY = love.graphics.getHeight() - table.maxn(exitNoteWraps) * font:getHeight() - margin local exitNoteY = love.graphics.getHeight() - table.maxn(exitNoteWraps) * textFont:getHeight() - margin
local checkboxSize = font:getBaseline() local checkboxSize = textFont:getBaseline()
local checkboxLine = love.graphics.getHeight()/180 local checkboxLine = love.graphics.getHeight()/180
local checkbox = Checkbox:new(checkboxSize, checkboxLine, love.math.newTransform(column2X, margin), false) local checkbox = Checkbox:new(checkboxSize, checkboxLine, love.math.newTransform(column2X, margin), false)
local showTime = checkbox.checked local showTime = checkbox.checked
@ -37,13 +38,13 @@ function love.load()
local textCanvas = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight()) local textCanvas = love.graphics.newCanvas(love.graphics.getWidth(), love.graphics.getHeight())
love.graphics.setCanvas(textCanvas) love.graphics.setCanvas(textCanvas)
love.graphics.setColor(1,1,1) love.graphics.setColor(1,1,1)
love.graphics.printf(" Show time", font, column2X + checkboxSize + checkboxLine, margin, column2Width) love.graphics.printf(" Show time", textFont, column2X + checkboxSize + checkboxLine, margin, column2Width)
love.graphics.printf("Press \"Esc\" to exit.", font, column2X, exitNoteY, column2Width) love.graphics.printf("Press \"Esc\" to exit.", textFont, column2X, exitNoteY, column2Width)
love.graphics.setCanvas() love.graphics.setCanvas()
local timeString local timeString
local timeIndent local timeIndent
local figureWidth = font:getWidth("0") local figureWidth = timeFont:getWidth("0")
clock.onSetHands = function(t) clock.onSetHands = function(t)
timeString = tostring(clock:getTime()) timeString = tostring(clock:getTime())
if #timeString < 5 then if #timeString < 5 then
@ -74,7 +75,7 @@ function love.load()
checkbox:draw() checkbox:draw()
love.graphics.draw(textCanvas, 0, 0) love.graphics.draw(textCanvas, 0, 0)
if showTime then if showTime then
love.graphics.printf(timeString, font, column2X+timeIndent, margin+font:getHeight(), column2Width) love.graphics.printf(timeString, timeFont, column2X+timeIndent, margin+textFont:getHeight(), column2Width)
end end
end end
end end