Code: Select all
local inventoryCanvasVertices = {}
local inventoryScreenVertices = {}
local inventoryWidth = 340
local contentHeight = 16000
local viewportHeight = 150
local inventoryContentCanvas = love.graphics.newCanvas(inventoryWidth, contentHeight)
local inventoryViewportCanvas = love.graphics.newCanvas(inventoryWidth, viewportHeight)
function drawInventory()
love.graphics.setCanvas(inventoryContentCanvas)
local topOffset = 180
-- important line 1
love.graphics.setColor(0, 0, 0, 1)
inventoryCanvasVertices = getBoxVertices(0, 0, inventoryWidth, contentHeight)
inventoryScreenVertices =
getBoxVertices(
uiManager.sideInfo.points.topLeft.x + uiManager.inventory.positionOffset.x + uiManager.sideInfo.padding,
uiManager.sideInfo.points.topLeft.y + uiManager.inventory.positionOffset.y + uiManager.sideInfo.padding + topOffset,
inventoryWidth,
contentHeight
)
-- important line 2
love.graphics.polygon("fill", inventoryCanvasVertices)
love.graphics.setColor(1, 1, 1, 1)
drawItem()
love.graphics.setCanvas(inventoryViewportCanvas)
love.graphics.draw(inventoryContentCanvas, 0, 0, 0, 1, 1, 0, uiManager.inventory.scrollOffset)
love.graphics.setCanvas()
love.graphics.draw(
inventoryViewportCanvas,
uiManager.sideInfo.points.topLeft.x + uiManager.inventory.positionOffset.x + uiManager.sideInfo.padding,
uiManager.sideInfo.points.topLeft.y + uiManager.inventory.positionOffset.y + uiManager.sideInfo.padding + topOffset
)
end
Now I am drawing the scrollable viewport in an area where I am already drawing a black background however I am drawing another black background in the content canvas which allows me to get the following results:
Initial I did not do this because I think I did not need to however if I remove the black background in the content canvas (the lines I commented as important 1 / 2), I get the following results:
So the main part of my question here is why would the text render different based on the background being nothing (or transparent) vs it explicitly being set as black when it is being drawing on top (a.k.a. after) a black box anyways (though on a different canvas)?
Now I am also opened to any suggestions / critiques people might have about my implementation of the scrollable content outside of you can using library X / Y / Z (part of the allure of using Love2D is that fact it's low level API is much simpler and I think, maybe naively, it is easier to do exactly want you want and nothing more than with something like Unity).