Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Mitigate issue where outline thicknesses less than 0.5 fail out generate solid shapes not outlines - #324

#324
Merged
JimBobSquarePants merged 1 commit into
mainSixLabors/ImageSharp.Drawing:mainfrom
issue323SixLabors/ImageSharp.Drawing:issue323Copy head branch name to clipboard
Mar 11, 2024
Merged

Mitigate issue where outline thicknesses less than 0.5 fail out generate solid shapes not outlines#324
JimBobSquarePants merged 1 commit into
mainSixLabors/ImageSharp.Drawing:mainfrom
issue323SixLabors/ImageSharp.Drawing:issue323Copy head branch name to clipboard

Conversation

@tocsoft

@tocsoft tocsoft commented Mar 8, 2024

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

If the outline thickness is going to trigger the noop behaviour of the clipper then scale the inputs and outputs to not trigger that behaviour.

I tried just removing the test in PolygonOffsetter.cs but for some reason that causes very small outlines to take significantly longer to generate than scaling up and down. (not investigated why).

This causes everything to generally render now, what it renders at particularly small sizes might not be the best (not investigated) but at least we generally render something better than the solid shape.

resolves #323

if the outline thickness is going to trigger the noop behaviour of the clipper then scale the inout and output to no trigger that behaviour.
IEnumerable<ISimplePath> paths = path.Flatten();
width = CalculateScalingMatrix(width, out Matrix3x2 scaleUpMartrix, out Matrix3x2 scaleDownMartrix);

IEnumerable<ISimplePath> paths = path.Transform(scaleUpMartrix).Flatten();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we only do this if the path is < .5f? It seems like we're adding overhead to all outline generation now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transform(...) is a no op (returning the original IPath) for Matrix3x2.Identity which will be return for sizes >= 0.5.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... Missed that. Looks good.

I'm hoping that once I get the new path stoker wired up this issue will go away.

@JimBobSquarePants JimBobSquarePants left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DrawPolygon with a thickness of less that 0.5 fills produces a filled polygon instead of a outline

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.