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

Filling a Polygon with LinearLineSegment causes a strange line leaving the drawing #122

Closed
zeroskyx opened this issue Mar 4, 2017 · 1 comment
Assignees

Comments

@zeroskyx
Copy link

zeroskyx commented Mar 4, 2017

The following code causes a strange line leaving the polygon to the right side:

image

`
using System.IO;
using System.Numerics;
using ImageSharp;
using ImageSharp.Drawing.Brushes;
using SixLabors.Shapes;

namespace Repro
{
	public class Program
	{
		public static void Run()
		{
			Vector2[] Points = new[]
			{
				new Vector2( 8, 8 ),
				new Vector2( 64, 8 ),
				new Vector2( 64, 64 ),
				new Vector2( 120, 64 ),
				new Vector2( 120, 120 ),
				new Vector2( 8, 120 )
			};

			using( Image ThisImage = new Image( 256, 128 ) )
			{
				ThisImage.Fill( new SolidBrush( new Color( 0xFF, 0xFF, 0xFF, 0xFF ) ) );

				ThisImage.Fill( new SolidBrush( new Color( 0x00, 0x00, 0x00, 0xFF ) ), new Polygon( new LinearLineSegment( Points ) ) );

				using( MemoryStream ThisBuffer = new MemoryStream() )
				{
					ThisImage.SaveAsPng( ThisBuffer );
					byte[] ThisByteArray = ThisBuffer.ToArray();
					File.WriteAllBytes( @"C:\Temp\Image.png", ThisByteArray );
				}
			}
		}
	}
}

`

The problem seems to be related to the fourth corner new Vector2( 120, 64 ) since slightly increasing the Y-coordinate no longer causes the line to appear: new Vector2( 120, 64.01f ):

image

@tocsoft
Copy link
Member

tocsoft commented Mar 4, 2017

The root cause of this bug was in the SixLabors.Shapes library.

This has now been fixed, if you update your ImageSharp.Drawing.Paths to 1.0.0-alpha2-00068 (which is just updates our SixLabors.Shapes dependency) then your issue is resolved.

The fix landed in SixLabors.Shapes 0.1.0-alpha0007

@tocsoft tocsoft closed this as completed Mar 4, 2017
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

No branches or pull requests

2 participants