You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
--Get Font
|
|
dofile("draw/characters")
|
|
|
|
--For each letter draw a character.
|
|
function drawText(gpu, cstring, x, y, red, green, blue, alpha)
|
|
for pos=1,string.len(cstring),1 do
|
|
drawChar(gpu, string.sub(string.lower(cstring), pos, pos), x + ((pos - 1) * 4), y, red, green, blue, alpha)
|
|
end
|
|
end
|
|
--Draw a single character.
|
|
function drawChar(gpu, character, x, y, red, green, blue, alpha)
|
|
gpured, gpublue, gpugreen, gpualpha = gpu.getColor()
|
|
red = red or gpured
|
|
blue = blue or gpublue
|
|
green = green or gpugreen
|
|
alpha = alpha or gpualpha
|
|
if (type(alpha) == "nil") then
|
|
alpha = 255
|
|
end
|
|
gpu.setColor(red, green, blue, alpha)
|
|
for ix=1,h,1 do
|
|
for iy=1,v,1 do
|
|
if (type(characters[character]) == "table") then
|
|
if(characters[character][iy][ix] == true) then
|
|
gpu.plot(ix+x,iy+y)
|
|
end
|
|
else
|
|
if(characters["?"][iy][ix] == true) then
|
|
gpu.setColor(255, 0, 0, 255)
|
|
gpu.plot(ix+x,iy+y)
|
|
else
|
|
gpu.setColor(0, 0, 0, 255)
|
|
gpu.plot(ix+x,iy+y)
|
|
end
|
|
gpu.setColor(red, green, blue, alpha)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|