2023-01-13 18:28:58 +00:00
|
|
|
--Render Sitelen Pona text. One file per glyph.
|
|
|
|
local love = love
|
|
|
|
local sp = {}
|
|
|
|
|
|
|
|
local info = love.filesystem.getInfo( "sitelenpona" )
|
|
|
|
for _, filename in ipairs(love.filesystem.getDirectoryItems( "sitelenpona" )) do
|
|
|
|
sp[filename:gsub( ".png", "" )] = love.graphics.newImage( "sitelenpona/"..filename )
|
|
|
|
end
|
2023-01-15 20:46:32 +00:00
|
|
|
--Render one or two glyphs in the center.
|
|
|
|
sp.Draw = function( t )
|
|
|
|
local cx, cy = love.graphics.getDimensions()
|
|
|
|
cx, cy = 0.5 * cx, 0.5 * cy
|
2023-01-14 13:59:20 +00:00
|
|
|
love.graphics.setColor( 1.0, 1.0, 1.0, 0.5 )
|
2023-01-15 20:46:32 +00:00
|
|
|
|
|
|
|
if #t == 1 then
|
|
|
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 128 )
|
|
|
|
elseif #t == 2 then
|
2023-01-16 02:38:15 +00:00
|
|
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 144, cy - 96, 0, 0.75, 0.75 )
|
|
|
|
love.graphics.draw( sp[t[2]] or sp.pilin, cx - 16, cy - 96, 0, 0.75, 0.75 )
|
2023-01-15 20:46:32 +00:00
|
|
|
elseif #t == 3 then
|
|
|
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 64, 0, 0.5, 0.5 )
|
|
|
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 64, 0, 0.5, 0.5 )
|
|
|
|
love.graphics.draw( sp[t[2]] or sp.pilin, cx, cy - 64, 0, 0.5, 0.5 )
|
|
|
|
end
|
|
|
|
--[[ w in str:gmatch( "%a+") do
|
|
|
|
t[i] = w
|
|
|
|
i = i + 1
|
|
|
|
end
|
|
|
|
for _, str in ipairs( t ) do
|
|
|
|
local w, h = love.graphics.getDimensions()
|
|
|
|
local x, y = 0.5 * w - 128, 0.5 * h - 128
|
|
|
|
|
|
|
|
love.graphics.draw( sp[str] or sp.pilin, x, y )
|
|
|
|
end]]
|
2023-01-13 18:28:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return sp
|