Example #1
0
        /// <summary>"Simplifies" the curve values ensuring that it's possible to offset the parts of the path.
        /// Used by the path stroke system.</summary>
        public void SimplifyCurve()
        {
            VectorPoint current = FirstPathNode;

            while (current != null)
            {
                if (current.IsCurve)
                {
                    CurveLinePoint clp = current as CurveLinePoint;

                    if (clp != null)
                    {
                        // Simplify:
                        clp.SimplifyCurve(this);
                    }
                    else
                    {
                        // Convert a QLP to a CLP:
                        QuadLinePoint qlp = current as QuadLinePoint;

                        if (qlp != null)
                        {
                            // Create but with both control points being the same:
                            clp           = new CurveLinePoint(qlp.X, qlp.Y);
                            clp.Control1X = qlp.Control1X;
                            clp.Control1Y = qlp.Control1Y;
                            clp.Control2X = qlp.Control1X;
                            clp.Control2Y = qlp.Control1Y;
                            clp.IsClose   = qlp.IsClose;

                            // Replace the node now:
                            if (qlp.Previous == null)
                            {
                                FirstPathNode = clp;
                            }
                            else
                            {
                                qlp.Previous.Next = clp;
                            }

                            if (qlp.Next == null)
                            {
                                LatestPathNode = clp;
                            }
                            else
                            {
                                qlp.Next.Previous = clp;
                            }
                        }
                    }
                }

                current = current.Next;
            }
        }