I'm new to Love2D but have prior experience in other languages and frameworks. I'm trying to draw the individual characters of a string around a circle, with the baseline of each character pointing to the circle's center, at a specified radius (imagine a clock face with roman numerals).
After reading about Canvas transformations and pulling my hair out a bit, I've come up with this, which works fine:
Code: Select all
function DrawString(letters, x, y, r)
love.graphics.push()
love.graphics.translate(x, y)
for i = 1, (#letters) do
local l = string.sub(letters, i, i)
local w = Font:getWidth(l) / 2 -- Font is defined globally
love.graphics.print(l, -w, -r * Screen.s) -- Screen.s adjusts for resolution scaling
love.graphics.rotate(math.pi * 2 / #letters)
end
love.graphics.pop()
end
Thanks for your help.