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

Please improve BezLength logic #39

Open
minudf opened this issue Aug 21, 2018 · 1 comment
Open

Please improve BezLength logic #39

minudf opened this issue Aug 21, 2018 · 1 comment

Comments

@minudf
Copy link

minudf commented Aug 21, 2018

Hello.
I need to improve performance while playing JSON.
I think below logic takes long time while Draw.
(There is TODO comment also)

Path.cs
internal static double BezLength(float c0X, float c0Y, float c1X, float c1Y, float c2X, float c2Y, float c3X, float c3Y)
{
const double steps = 1000d; // TODO: improve

            var length = 0d;
            float prevPtX = 0;
            float prevPtY = 0;

            for (var i = 0d; i < steps; i++)
            {
                var pt = GetPointAtT(c0X, c0Y, c1X, c1Y, c2X, c2Y, c3X, c3Y, i / steps);

                if (i > 0)
                {
                    var x = pt.X - prevPtX;
                    var y = pt.Y - prevPtY;
                    length = length + Math.Sqrt(x * x + y * y);
                }

                prevPtX = pt.X;
                prevPtY = pt.Y;
            }
            return length;
        }

Please check it.
Thank you.

@azchohfi
Copy link
Owner

azchohfi commented Sep 7, 2018

@minudf Have you tried the newest version? There was a great improvement on the rendering performance.

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