This creates an icon by using a 2D array to set pixel colors.
function setup()
pix = {width = 9, height = 9,
{20,20,20,20,20,20,20,20,20},
{20, 0, 0, 0, 0, 0, 0, 0,20},
{20, 0, 0, 0,20, 0, 0, 0,20},
{20, 0, 0, 0,20, 0, 0, 0,20},
{20, 0,20,20,20,20,20, 0,20},
{20, 0, 0, 0,20, 0, 0, 0,20},
{20, 0, 0, 0,20, 0, 0, 0,20},
{20, 0, 0, 0, 0, 0, 0, 0,20},
{20,20,20,20,20,20,20,20,20},
}
icon = image(pix.width, pix.height)
for y = 1, pix.height do
for x = 1, pix.width do
local t = pix[pix.height - y + 1][x]
icon:set(x,y, 255, 255, 255, t/20 * 255)
end
end
end
function draw()
background(40, 40, 50)
noSmooth()
sprite(icon, WIDTH/2, HEIGHT/2, HEIGHT/2, HEIGHT/2)
end