Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering along open paths. #263

Merged
merged 5 commits into from
Apr 4, 2023
Merged

Fix rendering along open paths. #263

merged 5 commits into from
Apr 4, 2023

Conversation

JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Mar 22, 2023

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

Fixes #234

The issue is caused by our code which calculates the position of a point along the given path at a given distance. The code works well for closed paths since it reduces the distance to the remainder (distance %= path.Length) which makes a nice loop.

For open paths we don't want to do that, we want to create a new virtual point at the correct angle and distance calculated from the last two points in the path.

I've also renamed DrawLines to DrawLine as you can only draw one line at a time using the method.

@JimBobSquarePants JimBobSquarePants requested review from tocsoft, antonfirsov, brianpopow and dlemstra and removed request for tocsoft March 22, 2023 07:20
@JimBobSquarePants JimBobSquarePants added this to the 1.0.0 milestone Mar 22, 2023
@@ -96,23 +95,6 @@ protected override void BeginText(in FontRectangle bounds)
}

this.DrawingOperations.Clear();

float yOffset = this.textOptions.VerticalAlignment switch
Copy link
Member Author

@JimBobSquarePants JimBobSquarePants Mar 22, 2023

Choose a reason for hiding this comment

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

Turns out we didn't actually need any of this and it was actually causing output to be rendered offset to where it should be.

@codecov
Copy link

codecov bot commented Mar 22, 2023

Codecov Report

Merging #263 (41174d1) into main (cee21d9) will increase coverage by 0%.
The diff coverage is 80%.

@@         Coverage Diff         @@
##           main   #263   +/-   ##
===================================
  Coverage    61%    61%           
===================================
  Files       100    100           
  Lines      6449   6427   -22     
  Branches   1378   1374    -4     
===================================
- Hits       3934   3923   -11     
+ Misses     2314   2308    -6     
+ Partials    201    196    -5     
Flag Coverage Δ
unittests 61% <80%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ImageSharp.Drawing/Shapes/ComplexPolygon.cs 76% <0%> (-3%) ⬇️
...mageSharp.Drawing/Shapes/PolygonClipper/Clipper.cs 73% <0%> (ø)
...rawing/Processing/Extensions/DrawLineExtensions.cs 100% <100%> (ø)
...rocessing/Processors/Text/RichTextGlyphRenderer.cs 95% <100%> (+1%) ⬆️
src/ImageSharp.Drawing/Shapes/InternalPath.cs 90% <100%> (+2%) ⬆️
...ImageSharp.Drawing/Shapes/Text/PathGlyphBuilder.cs 75% <100%> (+9%) ⬆️
src/ImageSharp.Drawing/Shapes/Text/TextBuilder.cs 62% <100%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@JimBobSquarePants
Copy link
Member Author

Would it be possible to get some eyes on this?

@JimBobSquarePants JimBobSquarePants mentioned this pull request Mar 30, 2023
8 tasks
@JimBobSquarePants JimBobSquarePants merged commit 1d451a2 into main Apr 4, 2023
@JimBobSquarePants JimBobSquarePants deleted the js/fix234 branch April 4, 2023 23:47
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.

TextBuilder.GenerateGlyphs places the characters incorrectly with the specific word 'all'
1 participant