H!,
I have a quad and need the get the pixels or getPixel, but that is not possible ?
https://love2d.org/wiki/Quad
And https://love2d.org/wiki/love.image.newImageData don't allow a Quad
https://love2d.org/wiki/ImageData
Thanks for the info?
Quad getPixel() or getPixels() not possible ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Quad getPixel() or getPixels() not possible ?
A quad is just a rectangle, so to say; it does not contain the image data itself, and you're right, ImageData does not support quads. But you can simulate it easily with Quad:getViewport:
If that function could receive pixels outside the quad extents, and you want to do something about it, you'll have to account for the width and height of the quad as well:
Code: Select all
local function getQuadPixel(imgData, quad, x, y)
local x0, y0 = quad:getViewport()
return imgData:getPixel(x - x0, y - y0)
end
Code: Select all
local function getQuadPixel(imgData, quad, x, y)
local x0, y0, w, h = quad:getViewport()
if x >= x0 and y >= y0 and x < x0 + w and y < y0 + h then
return imgData:getPixel(x - x0, y - y0)
end
-- Do something to deal with coordinates out of the quad.
-- In the example below, it reports an error.
error("Coordinates out of the quad")
end
Re: Quad getPixel() or getPixels() not possible ?
Ah din't know about the quad viewport. Thanks!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests