Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Shape::Line offset problem  (Read 1295 times)

0 Members and 1 Guest are viewing this topic.

sPirc

  • Newbie
  • *
  • Posts: 3
    • View Profile
sf::Shape::Line offset problem
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Shape::Line offset problem
« Reply #1 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.
Laurent Gomila - SFML developer