38 lines
1.3 KiB
Lua
38 lines
1.3 KiB
Lua
--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
|
|
--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
|
|
love.graphics.setColor( 1.0, 1.0, 1.0, 0.5 )
|
|
|
|
if #t == 1 then
|
|
love.graphics.draw( sp[t[1]] or sp.pilin, cx - 128, cy - 128 )
|
|
elseif #t == 2 then
|
|
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 )
|
|
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]]
|
|
end
|
|
|
|
|
|
return sp |