Rectangles drawn with love.graphics.rectangle are (at least on love 0.8.0) automatically two or three pixels wide love.graphics.setLineWidth doesn't help, it's kind of a minor thing but it would be nice if love.graphics.setLineWidth(1) made rectangles have a line width of 1.
(solved) Rectangle lines are to thick
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- mcjohnalds45
- Prole
- Posts: 18
- Joined: Sat Jun 02, 2012 12:08 pm
(solved) Rectangle lines are to thick
- Attachments
-
- rectangle glitch.love
- does a three line program really need a .love? lmao
- (235 Bytes) Downloaded 57 times
Last edited by mcjohnalds45 on Sun Jun 17, 2012 10:53 am, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Rectangle lines are to thick
This is something we've been struggling with, and actually, the line is one pixel wide, but it's drawn between two pixels, interpolating it to two (about) half-filled pixels.
As a temporary solution, you could move your rectangle by (0.5, 0.5).
As a temporary solution, you could move your rectangle by (0.5, 0.5).
- mcjohnalds45
- Prole
- Posts: 18
- Joined: Sat Jun 02, 2012 12:08 pm
Re: Rectangle lines are to thick
That works perfectly, thanks a bunch bartbes!
Re: Rectangle lines are to thick
Would it be possible to automatically move it down and right half a pixel in drawing?
Re: Rectangle lines are to thick
i wonder if love itself could cheat and do a translate call each frame in love.runKingdaro wrote:Would it be possible to automatically move it down and right half a pixel in drawing?
who knows what that would potentially mess up, though
Re: Rectangle lines are to thick
In my opinion, LÖVE should not do any shifting by default. It currently places the center of the line exactly where you specify it. Adding some shifting rule complicates this for no good reason. Also, only odd line widths need the 0.5 shift to get them into the position where it matches the pixels exactly. The even widths need coordinates inbetween the pixel for that.
Shallow indentations.
Re: Rectangle lines are to thick
Also, try setting the line style to "rough" before drawing lines. I am able to get lines drawn at whole integers using this, without having to add 0.5 to the position values.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Rectangle lines are to thick
Note that this will only work as long as FSAA/multisampling is turned off.Lafolie wrote:Also, try setting the line style to "rough" before drawing lines. I am able to get lines drawn at whole integers using this, without having to add 0.5 to the position values.
There's a way for doing the shift automatically. Well... If love.graphics.getLineWidth would actually work (it's broken in 0.8.0 and I push a patch to the developers right now) you could do something like this:
Code: Select all
local l_g_rectangle = love.graphics.rectangle
function love.graphics.rectangle(style, x, y, ...)
if style == "line" then
local offset = love.graphics.getLineWidth() / 2 % 1
x = x + offset
y = y + offset
end
l_g_rectangle(style, x, y, ...)
end
Shallow indentations.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 64 guests