Yesterday I tried to spiffy up some of my info panels by adding a single pixel line around them. What I got was a lined rectangle with its top left X coord offset by -1 and its height offset by +1. Here is some test code and an image pointing this out:
Main.lua
Code: Select all
io.stdout:setvbuf ("no")
function love.load()
fonts = {
default = love.graphics.newFont(12),
}
TileX, TileY = 24, 24
end
function love.update(dt)
end
function love.keypressed(key)
if key == "escape" then
love.event.push("quit")
end
end
function love.mousepressed(x, y, button)
end
function love.draw()
-- Draw 1st test boxes
love.graphics.setFont(fonts.default)
love.graphics.setColor(42, 52, 118, 255)
love.graphics.rectangle( "fill", 2*TileX, 2*TileY, 164, 6*TileY )
-- Draw fake date header
love.graphics.setColor(192, 192, 192, 255)
love.graphics.rectangle( "fill", 2*TileX, 1*TileY, 164, 1*TileY )
-- fake date text
love.graphics.setColor(0, 0, 0, 255)
love.graphics.printf("Box 1", 2*TileX, 1*TileY, 164, "center")
-- Draw 2nd test boxes
love.graphics.setFont(fonts.default)
love.graphics.setColor(42, 52, 118, 255)
love.graphics.rectangle( "fill", 10*TileX, 2*TileY, 164, 6*TileY )
-- Draw a border line around box
love.graphics.setLineWidth(1)
love.graphics.setLineStyle("rough")
love.graphics.setColor(255, 255, 255, 255)
love.graphics.rectangle( "line", 10*TileX, 2*TileY, 164, 6*TileY )
-- Draw fake date header
love.graphics.setColor(192, 192, 192, 255)
love.graphics.rectangle( "fill", 10*TileX, 1*TileY, 164, 1*TileY )
-- fake date text
love.graphics.setColor(0, 0, 0, 255)
love.graphics.printf("Box 2 Border Line", 10*TileX, 1*TileY, 164, "center")
-- **Draw 3rd test boxes**
love.graphics.setFont(fonts.default)
love.graphics.setColor(192, 0, 0, 255)
love.graphics.rectangle( "fill", 18*TileX, 2*TileY, 164, 6*TileY )
-- Draw a border line around box
love.graphics.setLineWidth(1)
love.graphics.setLineStyle("rough")
love.graphics.setColor(255, 255, 255, 255)
-- ****** Why THIS need to compensate? *******
love.graphics.rectangle( "line", 18*TileX+1, 2*TileY, 164-1, 6*TileY-1 )
-- *******************************************
-- Draw fake date header
love.graphics.setColor(192, 192, 192, 255)
love.graphics.rectangle( "fill", 18*TileX, 1*TileY, 164, 1*TileY )
-- fake date text
love.graphics.setColor(0, 0, 0, 255)
love.graphics.printf("Box 3 line Compensate", 18*TileX, 1*TileY, 164, "center")
end
Thanks