Hello all,
I'm quite new to löve, so please permit me this n00b question
I'm trying to draw a loaded image on the screen with love.graphics.draw(), but only a rectangular part of it.
However, draw() doesn't do clipping.
What would be the right way to do that?
Thanks! vitaminx
How can I clip with love.graphics.draw()
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How can I clip with love.graphics.draw()
experimental art since 13.75 gigayears
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: How can I clip with love.graphics.draw()
Welcome!
You can do that with love.graphics.setScissor:
You can do that with love.graphics.setScissor:
Code: Select all
love.graphics.setScissor(10, 10, 100, 100)
love.graphics.draw(image, 10, 10)
love.graphics.setScissor() -- disable the clipping
Help us help you: attach a .love.
- slime
- Solid Snayke
- Posts: 3132
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: How can I clip with love.graphics.draw()
You can also use Quads.
Re: How can I clip with love.graphics.draw()
It sounds more like a job for Quads and love.graphics.drawq than a job for love.graphics.setScissor. But they'll both work.
Quads can be added to Spritebatches and Canvases as well if you want to use buffers.
Quads can be added to Spritebatches and Canvases as well if you want to use buffers.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: How can I clip with love.graphics.draw()
thanks a lot, I'm now using quads which are exactly what I needed.
experimental art since 13.75 gigayears
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
https://github.com/humansarepuppies
http://stardiaries-lab.blogspot.com/
Re: How can I clip with love.graphics.draw()
omg. ty sir was searching all over for this.Robin wrote: ↑Fri Oct 19, 2012 7:59 am Welcome!
You can do that with love.graphics.setScissor:
Code: Select all
love.graphics.setScissor(10, 10, 100, 100) love.graphics.draw(image, 10, 10) love.graphics.setScissor() -- disable the clipping
this works perfectly for health globes!
man, i'm really starting to like love2d
- zorg
- Party member
- Posts: 3441
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How can I clip with love.graphics.draw()
the scissor thing works in screenspace though, no transformations will affect it, so keep this in mind when you get to rotating/scaling stuff, since then, scissors won't exactly work.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: Google [Bot] and 75 guests