Page 1 of 1

Centering a rectangle

Posted: Thu Nov 22, 2018 1:59 pm
by Purple Fedora

Code: Select all

	canvas = love.graphics.newCanvas(values.width, values.height, {type="2d"}, {format="normal"}, 1)
	love.graphics.setCanvas(canvas)
	love.graphics.clear()
	love.graphics.setColor(blue.r, blue.g, blue.b, blue.a)
	love.graphics.rectangle("fill", 0, 0, values.width, values.width)
	love.graphics.setColor(red.r, red.g, red.b, red.a)
	love.graphics.rectangle("fill", 0, values.width, values.width, values.width)
	love.graphics.setLineWidth(values.edge)
	love.graphics.setColor(0, 0, 0, 0.3)
	love.graphics.rectangle("line", values.edge / 2, values.edge / 2, values.width - values.edge, values.height - values.edge)
	love.graphics.setCanvas()
Why does the darker rectangle look on this canvas so out of the center, did i mess up the code or is it an optical illusion?