SFML community forums

Help => Graphics => Topic started by: Sajmon on November 05, 2018, 09:46:53 pm

Title: Simple way of avoiding scaled outlines
Post by: Sajmon 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.


(http://Caputre.PNG)
Title: Re: Simple way of avoiding scaled outlines
Post by: Hapax 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.
Title: Re: Simple way of avoiding scaled outlines
Post by: Sajmon 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.

(:
Title: Re: Simple way of avoiding scaled outlines
Post by: Sajmon 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.