Hi,
I'm trying to load a large .png image and draw only part of it to a canvas. My understanding is that I should use a quad to lift part of the image and then draw that, but I'm not seeing how to aim the newQuad() function. It's arguments don't include an image/texture/whatever argument and I don't see an equivalent of newCanvas() for these object types. How do I target the correct source when making a quad?
I'm using v11.4, in case it matters. Help is appreciated.
EDIT: Sorry, I meant "an equivalent of setCanvas()", not newCanvas().
How do I target the newQuad() function?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How do I target the newQuad() function?
So you want to use the
https://love2d.org/wiki/love.graphics.draw
and you want to create it as
https://love2d.org/wiki/love.graphics.newQuad
It works as:
For my opinion, the quad must have the reference to the image that it uses for using as love.graphics.drawQuad(quad,x,y), all needed references must be inside the quad, but it doesn't work (now).
https://love2d.org/wiki/love.graphics.draw
Code: Select all
love.graphics.draw ( texture, quad, x, y )
https://love2d.org/wiki/love.graphics.newQuad
Code: Select all
quad = love.graphics.newQuad ( x, y, width, height, texture )
Code: Select all
local x, y, w, h = 10, 10, 32, 16 -- quad position and quad size
local image = love.graphics.newImage ("spritesheet.png")
local quad = love.graphics.newQuad ( x, y, w, h, image )
object = {
x = 20, y=30, -- position of object
quad = quad,
image = image,
}
-- draw:
love.graphics.draw ( object.image, object.quad, object.x, object.y)
For my opinion, the quad must have the reference to the image that it uses for using as love.graphics.drawQuad(quad,x,y), all needed references must be inside the quad, but it doesn't work (now).
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: How do I target the newQuad() function?
a quad contains cut and scale information.
Binding that to a picture would be contraproductive since using a quad on different pictures is a thing.
Binding that to a picture would be contraproductive since using a quad on different pictures is a thing.
obey
Re: How do I target the newQuad() function?
You are right, but the other picture can be optional, if you had just one picture then you could not provide any other information, just render quad in the given position with default picture, that was based on.BrotSagtMist wrote: ↑Wed Aug 24, 2022 11:06 am a quad contains cut and scale information.
Binding that to a picture would be contraproductive since using a quad on different pictures is a thing.
Re: How do I target the newQuad() function?
That's what I was missing. For some reason I was assuming that only the version of a function at the top of the page was legit and the lower ones were obsolete. Not sure why. But it caused me to miss that.
Thanks.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 2 guests