Drawing an Image FROM and Image

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
NeoFLoyd
Prole
Posts: 11
Joined: Tue Oct 18, 2011 12:30 am

Drawing an Image FROM and Image

Post 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!
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Drawing an Image FROM and Image

Post by thelinx »

Looks like you need to learn about ParticleSystems.

You can find example code in particles.love in the demos zip archive.
NeoFLoyd
Prole
Posts: 11
Joined: Tue Oct 18, 2011 12:30 am

Re: Drawing an Image FROM and Image

Post 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.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Drawing an Image FROM and Image

Post by Taehl »

Define "draw an image from an image".
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
NeoFLoyd
Prole
Posts: 11
Joined: Tue Oct 18, 2011 12:30 am

Re: Drawing an Image FROM and Image

Post 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.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Drawing an Image FROM and Image

Post 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).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
NeoFLoyd
Prole
Posts: 11
Joined: Tue Oct 18, 2011 12:30 am

Re: Drawing an Image FROM and Image

Post by NeoFLoyd »

Darn,it stinks that there's no way to make one of these ribbons.Thanks for the useful info anyway!
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Drawing an Image FROM and Image

Post 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.
Attachments
ribbons.love
0.8.0
(147.93 KiB) Downloaded 156 times
NeoFLoyd
Prole
Posts: 11
Joined: Tue Oct 18, 2011 12:30 am

Re: Drawing an Image FROM and Image

Post 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?
User avatar
pk
Citizen
Posts: 67
Joined: Wed Dec 14, 2011 2:13 am
Location: Texas, United States
Contact:

Re: Drawing an Image FROM and Image

Post 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.
ALL CREATURE WILL DIE AND ALL THE THINGS WILL BE BROKEN. THAT'S THE LAW OF SAMURAI.
Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests