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

Author Topic: Simple way of avoiding scaled outlines  (Read 2165 times)

0 Members and 1 Guest are viewing this topic.

Sajmon

  • Newbie
  • *
  • Posts: 16
    • View Profile
Simple way of avoiding scaled outlines
« on: November 05, 2018, 09:46:53 pm »
Is there a clean/simple way of making the outlines of a sf::Shape not get affected by scale?
(See attached picture to see what I mean.)

Because I can't decrease the scaling by setting another OutlineThickness, because on different scales, horizontal and vertical get affected differently..

I could do this as a seperate shader, I guess.
But I want to avoid that.

And I COULD use sf::RectangleShape::SetSize() instead of using Scale at all.
But I've built everything around SetScale now, because I'm only using sf::Shape pointers everywhere, and I don't want to cast all the time.


« Last Edit: November 05, 2018, 10:01:05 pm by Sajmon »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Simple way of avoiding scaled outlines
« Reply #1 on: November 07, 2018, 10:56:42 pm »
Unfortunately, no. Scaling scales the entire object - outline included.
As you've mentioned, the workaround would be to manually adjust their sizes since this is independant of the outline.
Casting isn't bad as long as it's clear to its intention.
That said, you could separate the different types of shapes and hold pointers to each one; that would remove casting. If you're only using rectangles, it's mostly just replacing sf::Shape with sf::RectangleShape.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Sajmon

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Simple way of avoiding scaled outlines
« Reply #2 on: November 08, 2018, 01:54:06 pm »
Yeah.
The only problem is that I have sf::ConvexShape and sf::CircleShape (and sf::RoundedRectangle) too.

So that leaves me to save a enum { Convex, Circle, Rectangle, Rounded }
1. Check type
2. Cast
3. Perform adjustment, SetSize() / SetRadius / Blabla

Meh, it'll work, I guess.

Thanks for the help pal.

(:

Sajmon

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Simple way of avoiding scaled outlines
« Reply #3 on: November 08, 2018, 07:30:41 pm »
FUCK.

Now the applied texture/sprite on the shapes doesn't get scaled.
God fucking damnit.

And I need to do SetOrigin() each time as well.