SFML community forums

Help => Graphics => Topic started by: sPirc on July 31, 2011, 01:30:10 pm

Title: sf::Shape::Line offset problem
Post by: sPirc on July 31, 2011, 01:30:10 pm
Hi.

I have a "problem" with sf::Shape::Line.

If I create two lines:

Code: [Select]

sf::Shape line1 = sf::Shape::Line(1, 1, 10, 1, 1, sf::Color::Red);
sf::Shape line2 = sf::Shape::Line(1, 1, 1, 10, 1, sf::Color::Blue);


then the second line ('line2', that goes vertically) is rendered as going from x position 0 rather than x position 1. I.e. The two lines don't overlap at position (1,1) as I would've expected.

Is this a normal thing? Is it correct? Is there something wrong with me or sfml? :)

I can take this deviation into account when drawing up stuff but right now it is just annoying.
Title: sf::Shape::Line offset problem
Post by: Laurent on July 31, 2011, 02:59:35 pm
Your vertical line is centered on y = 1, with thickness = 1. Therefore it goes from y = 0.5 to y = 1.5. But to fill exactly the second column of pixels, it should rather go from y = 1 to y = 2. So, instead of centering it on y = 1, center it on y = 1.5.

Same for the horizontal line.