SixLabors / ImageSharp.Drawing

:pen: Extensions to ImageSharp containing a cross-platform 2D polygon manipulation API and drawing operations.
https://sixlabors.com/products/imagesharp-drawing/
Other
282 stars 38 forks source link

Fix rendering along open paths. #263

Closed JimBobSquarePants closed 1 year ago

JimBobSquarePants commented 1 year ago

Prerequisites

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.

codecov[bot] commented 1 year ago

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%) :arrow_up:

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%) :arrow_down:
...mageSharp.Drawing/Shapes/PolygonClipper/Clipper.cs 73% <0%> (ø)
...rawing/Processing/Extensions/DrawLineExtensions.cs 100% <100%> (ø)
...rocessing/Processors/Text/RichTextGlyphRenderer.cs 95% <100%> (+1%) :arrow_up:
src/ImageSharp.Drawing/Shapes/InternalPath.cs 90% <100%> (+2%) :arrow_up:
...ImageSharp.Drawing/Shapes/Text/PathGlyphBuilder.cs 75% <100%> (+9%) :arrow_up:
src/ImageSharp.Drawing/Shapes/Text/TextBuilder.cs 62% <100%> (ø)

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

JimBobSquarePants commented 1 year ago

Would it be possible to get some eyes on this?