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

Wrong calculation of path's intersection. #655

Open
pcerman opened this issue Oct 18, 2018 · 0 comments
Open

Wrong calculation of path's intersection. #655

pcerman opened this issue Oct 18, 2018 · 0 comments

Comments

@pcerman
Copy link

pcerman commented Oct 18, 2018

Description

Many times SkiaSharp doesn't calculate intersection of two paths well. Result path contains no points. For example next dotNet core console application is not able to calculate intersection. It writes 0 on console.

The same example in C++ is working well. You can try it in the next fiddle record:

https://fiddle.skia.org/c/cde611c02e7cfb956670649610eb40d3

Code

    class Program
    {
        private static float SkBits2Float(uint n)
        {
            byte[] data = BitConverter.GetBytes(n);
            return BitConverter.ToSingle(data, 0);
        }

        static void Main(string[] args)
        {
            SKPath path_a = new SKPath();

            path_a.FillType = SKPathFillType.Winding;

            path_a.MoveTo(SkBits2Float(0x00000000), SkBits2Float(0x44070000));
            path_a.LineTo(SkBits2Float(0x44340000), SkBits2Float(0x44070000));
            path_a.LineTo(SkBits2Float(0x44340000), SkBits2Float(0x00000000));
            path_a.LineTo(SkBits2Float(0x00000000), SkBits2Float(0x00000000));
            path_a.Close();

            SKPath path_b = new SKPath();

            path_b.FillType = SKPathFillType.EvenOdd;

            path_b.MoveTo(SkBits2Float(0xB6D27CA9), SkBits2Float(0x44070000));
            path_b.LineTo(SkBits2Float(0x44340000), SkBits2Float(0x44070000));
            path_b.LineTo(SkBits2Float(0x44340000), SkBits2Float(0x36CCD0F6));
            path_b.LineTo(SkBits2Float(0xB6D27CA9), SkBits2Float(0x36CCD0F6));
            path_b.Close();

            SKPath path_r = path_a.Op(path_b, SKPathOp.Intersect);

            if (path_r != null)
            {
                Console.WriteLine(path_r.PointCount);
            }
        }
    }

Expected Behavior

It has to calculate intersection well as the fiddle example (result path is rendered by green color).

Basic Information

  • Version with issue: SkiaSharp nuget package 1.60.3
  • IDE: Visual Studio 2017 version 15.8.7
  • Platform Target Frameworks: .NET Core 2.1

Example was tested on Windows 10

VS bug #738688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: New
Development

No branches or pull requests

3 participants