Fandom

Pico-8 Wiki

Centering Text

162pages on
this wiki
Add New Page
Comments0 Share
textlabel="this is some cool text!!!"



function hcenter(s)

-- string length times the 

-- pixels in a char's width

-- cut in half and rounded down

return 64-flr((#s*4)/2)

end



function vcenter(s)

-- string char's height

-- cut in half and rounded down

return 64-flr(5/2)

end


function _draw()

rectfill(0,0,128,128,0)

print(textlabel,hcenter(textlabel),vcenter(textlabel),8)

end

 

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.