DEV Community

Cover image for Drawing a lövely image
Talles L
Talles L

Posted on

Drawing a lövely image

Drawing an image file:

function love.load()
    mario = love.graphics.newImage("mario.png")
end

function love.draw()
    love.graphics.draw(mario)
end
Enter fullscreen mode Exit fullscreen mode

Drawing an image from base64 on source code:

mario64 = "iVBORw0KGgoAAAANSUhEUgAAAQQAAAEEBAMAAAA8Jlc5AAAAElBMVEUAAAAAAACIcADYKAD8mDj///9LiYtiAAAAAXRSTlMAQObYZgAAAAFiS0dEBfhv6ccAAAEsSURBVHja7d3BDYUgEAVAWqCF34It2H9N/+RlEwIiUcF5R4zuHDdhwZTyw0mpnbA1BgEBAQEBAeF7hG1QEBAQEBAQENYl/ArZQ+L6wJYFAQEBAQEB4aWE+MlS6dbnCAgICAgICN8hDKYgICAgICAgLECofbJEjLnQsiAgICAgICC8lBCzd2bg1CcCAgICAgLCSwmx9ThGKE+2JggICAgICAgLEkolSoROGgICAgICAsKEhNrWRu3o5smtEQQEBAQEBIQJCaXRiKPEsR5Lx/XS6AUCAgICAgLCeoRSyVouHNFAQEBAQEBAmIxw9WpJBAQEBAQEhPUIMa1XTHf+0gIBAQEBAQFhYkLvEYwbpj4REBAQEBAQHiZ0Xv3U+z4CAgICAgLChISbg5BzzukP4FDNAIC3HvUAAAAASUVORK5CYII="

byte_data = love.data.decode('data', 'base64', mario64)
image_data = love.image.newImageData(byte_data)
image = love.graphics.newImage(image_data)

function love.draw()
    love.graphics.draw(image)
end
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.