graphics.print & graphics.printf consider its x, y parameters as "bottom-left" but the rest of graphics functions use them as "top-left".
For example, I've done a function that prints a text with background color (using rectangle)
Code: Select all
function colorPrint(text, x, y, fontColor, backgroundColor, font, fontHeight)
-- ... (fill fontColor, backGroundColor, font & fontHeight with default values)
local width = font:getWidth(text)
-- draw the rectangle
love.graphics.setColor(unpack(backgroundColor))
love.graphics.rectangle( "fill", x, y, width, fontHeight )
love.graphics.print(text, x, y)
-- print the text
love.graphics.setFont(font, fontHeight)
love.graphics.setColor(unpack(fontColor))
love.graphics.print(text, x, y)
end
Code: Select all
My Sample Text
+----------------+
| |
+----------------+
Code: Select all
love.graphics.print(text, x, y-fontHeight)