Page 1 of 2

Drawing an Image FROM and Image

Posted: Thu Dec 15, 2011 12:23 am
by NeoFLoyd
I'm still learning a little Lua, though I have a decent understanding of how it works. Being the newbie I am I have become stumped.

Say I have an image called "rake.png." It is draggable by the mouse. How can I draw an image called "raketrail.png" from rake.png if rake is being dragged?

Much appreciated!

Re: Drawing an Image FROM and Image

Posted: Thu Dec 15, 2011 1:15 am
by thelinx
Looks like you need to learn about ParticleSystems.

You can find example code in particles.love in the demos zip archive.

Re: Drawing an Image FROM and Image

Posted: Thu Dec 15, 2011 1:48 am
by NeoFLoyd
thelinx wrote:Looks like you need to learn about ParticleSystems.

You can find example code in particles.love in the demos zip archive.

Oh my ... that seems very complex. Would anyone be able to just post a finished code based on what I asked for? Although I'm definitely going to read up on what Linx posted, I also learn fairly well from examining the code myself.

Re: Drawing an Image FROM and Image

Posted: Thu Dec 15, 2011 2:53 am
by Taehl
Define "draw an image from an image".

Re: Drawing an Image FROM and Image

Posted: Thu Dec 15, 2011 11:02 am
by NeoFLoyd
Taehl wrote:Define "draw an image from an image".
Say I have an image called rake.png and it is draggable. I would like an image named raketrail.png to become drawn from the mouse while rake.png is dragged.

Re: Drawing an Image FROM and Image

Posted: Fri Dec 16, 2011 1:37 am
by Taehl
So far as I know, the name for that sort of thing is a "ribbon" (at least, that's what Blizzard calls them in all their games). Love, unfortunately, doesn't offer a way of drawing ribbons (yet?). I wish it did, though.

However, even if there isn't a proper way to do it, you can still fake it. A few possibilities I can think of:
- Make it pixel-art or somehow tile-based, so you don't need to draw an exact, detailed trail
- Draw a circle under each tine every frame that the rake is down, but draw it to a framebuffer instead of the screen. As long as you don't clear the framebuffer, you'll get the furrow trails you want.
- Make your own ribbon system using lots of image transforms (I'd suggest looking into the 3D dice roller demo to see the math and methods for skewing an image).

Re: Drawing an Image FROM and Image

Posted: Fri Dec 16, 2011 10:57 am
by NeoFLoyd
Darn,it stinks that there's no way to make one of these ribbons.Thanks for the useful info anyway!

Re: Drawing an Image FROM and Image

Posted: Sat Dec 17, 2011 5:05 am
by TechnoCat
Taehl wrote:Love, unfortunately, doesn't offer a way of drawing ribbons (yet?). I wish it did, though.
Create a blank framebuffer and draw to it without clearing. Every frame decrement the opacity of each pixel. I can't remember if 0.7.2 has the explicit framebuffer clearing or if 0.8.0 does.

EDIT: Indeed it requires LOVE 0.8.0. BEWARE! This example isn't dt based.

Re: Drawing an Image FROM and Image

Posted: Sat Dec 17, 2011 9:46 pm
by NeoFLoyd
TechnoCat wrote:
Taehl wrote:Love, unfortunately, doesn't offer a way of drawing ribbons (yet?). I wish it did, though.
Create a blank framebuffer and draw to it without clearing. Every frame decrement the opacity of each pixel. I can't remember if 0.7.2 has the explicit framebuffer clearing or if 0.8.0 does.

EDIT: Indeed it requires LOVE 0.8.0. BEWARE! This example isn't dt based.
How would one obtain LOVE 0.8.0?

Re: Drawing an Image FROM and Image

Posted: Sat Dec 17, 2011 10:09 pm
by pk
It's not out yet, but if you're running Windows, you can get nightly builds here:

http://love2d.org/builds/

Beware that stuff which works fine on the wiki/forums for 0.7.2 might fail horribly under 0.8.0.