I'm currently working on a project that I call "Helium" (see link to project below), it's pretty much done but when I asked a fellow Löve user they said this:
So I have decided to do a small side project that focuses on saving and canvas functions, so I have made a square in the middle of my screen and to colour it I'm using math.random(0, 255) so every colour is different every time.A paint program would really benefit from using canvases. Actually they'd pretty much be required. The way you have it now works fine at first, but eventually is going to grind to a halt because you're looping through each square every frame. Plus a canvas could be saved just as easy as a screenshot.
You might benefit better from creating a thread if you haven't yet. But a canvas would be my first suggestion.
I also have a light blue "Ui" at the bottom of the screen and I also have a save icon at the bottom right of the screen inside the Ui.
What I'm wondering is:
1. How does the canvas function actually work?
2. How can I make it so that I draw inside the canvas?
3. How can I save the canvas as a "screenshot"?
4. Is there anything else that I should know about canvases?
5. Does anyone have a good example on how to save images in Löve according to the questions I have just asked?
The idea of this small project is that when I save the image/canvas of the flashing square it will save the colour it currently have, as math.random switches colours every frame (From what I understand how it works) it will save the image in a still frame.
Here's a link to a previous thread that I asked on how to save images:
http://www.love2d.org/forums/viewtopic.php?f=3&t=78913
I hope that I have made myself clear with my questions and I thank you for helping me out.
My small side project:
Code: Select all
function love.load()
canvas = love.graphics.newCanvas(800, 480)
-- Images --
-- Floppy Disc Save Icon
saveIcon = love.graphics.newImage("saveIcon.png")
-- Blue User Interface Bar
ui = love.graphics.newImage("blueUI.png")
end
function love.update()
end
function love.draw()
love.graphics.setBackgroundColor(255, 255, 255)
-- Square With Random Color
love.graphics.setColor( math.random(0, 255), math.random(0, 255), math.random(0, 255) )
love.graphics.rectangle("fill", 350, 250, 120, 120)
-- Part Of The User Interface --
-- User Interface
love.graphics.setColor(255, 255, 255)
love.graphics.draw(ui, 0, 480)
-- Save Icon
love.graphics.draw(saveIcon, 675, 500)
end
https://www.dropbox.com/s/syex5uxkptox0 ... m.zip?dl=0