So I found a solution.
Code: Select all
function getOddImage(coords, img)
local palette = love.graphics.newFramebuffer()
local cx,cy,cr = unpack(coords)
cx, cy = cr, cr
local diam = cr*2
local image = love.graphics.newImage(img) --it's assumed that img is a proper path.
local quad = love.graphics.newQuad(0,0, diam,diam, image:getWidth(),image:getHeight())
love.graphics.setRenderTarget(palette)
love.graphics.setColor(255,255,255)
love.graphics.circle('fill',cx, cy, cr,32)
love.graphics.drawq(woodImg, quad, 0,diam)
local data = palette:getImageData()
local circleData = love.image.newImageData(diam, diam)
local r1,g1,b1,a1
local r2,g2,b2,a2
for x=0,diam-1 do
for y=0, diam-1 do
r1,g1,b1,a1 = data:getPixel(x,y) --a pixel from the target circle
r2,g2,b2,a2 = data:getPixel(x, y+diam) --a pixel from the quad/wood
if a1 == a2 then
circleData:setPixel(x,y, r2,g2,b2,a2)
end
end
end
love.graphics.setRenderTarget()
return love.graphics.newImage(circleData)
end
(It should be noted that the Framebuffer, palette, is created outside of the function. It's included here for completeness. Creating a framebuffer every time this is called would be a major waste!)
Basically, I create my own image of a circle with the wood grain texture on it. When the circular platform that called this function is drawn, the image created here is used. This is much simpler than what I had been trying to do before (it only uses one Framebuffer instead of, say, 3 or so) and I don't think it'll be super laggy. Of course, large circle will present a problem, and eventually this should probably be written in C to speed things up. But hey, it works.