Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
        public override VectorPoint Copy()
        {
            QuadLinePoint point = new QuadLinePoint(X, Y);

            point.Length = Length;

            point.Control1X = Control1X;
            point.Control1Y = Control1Y;

            return(point);
        }
Ejemplo n.º 3
0
        public override VectorPoint PointAt(float t, bool addNext)
        {
            float invert = 1f - t;

            float p0x = Previous.X;
            float p0y = Previous.Y;

            float p1x = Control1X;
            float p1y = Control1Y;

            float p2x = X;
            float p2y = Y;

            // The new points:
            float p3x = p0x * invert + p1x * t;
            float p3y = p0y * invert + p1y * t;

            float p4x = p1x * invert + p2x * t;
            float p4y = p1y * invert + p2y * t;

            float p5x = p3x * invert + p4x * t;
            float p5y = p3y * invert + p4y * t;

            // This curve will become the new 1st half:
            QuadLinePoint from = new QuadLinePoint(p5x, p5y);

            from.Control1X = p3x;
            from.Control1Y = p3y;

            if (addNext)
            {
                // Create the next one:
                QuadLinePoint to = new QuadLinePoint(p2x, p2y);

                to.Control1X = p4x;
                to.Control1Y = p4y;

                // Update length:
                to.Length = invert * Length;

                to.Previous = from;
                from.Next   = to;

                if (IsClose)
                {
                    to.IsClose = true;
                }
            }

            from.Length = t * Length;

            return(from);
        }
Ejemplo n.º 4
0
        public QuadLinePoint QuadraticCurveTo(float cx, float cy, float x, float y)
        {
            // Create the curve line:
            QuadLinePoint newNode = new QuadLinePoint(x, y);

            newNode.Control1X = cx;
            newNode.Control1Y = cy;

            // Add it:
            AddPathNode(newNode);

            return(newNode);
        }
		public override VectorPoint Split(float t,VectorPath path){
			
			float invert=1f-t;
			
			float p0x=Previous.X;
			float p0y=Previous.Y;
			
			float p1x=Control1X;
			float p1y=Control1Y;
			
			float p2x=X;
			float p2y=Y;
			
			// The new points:
			float p3x=p0x * invert + p1x * t;
			float p3y=p0y * invert + p1y * t;
			
			float p4x=p1x * invert + p2x * t;
			float p4y=p1y * invert + p2y * t;
			
			float p5x=p3x * invert + p4x * t;
			float p5y=p3y * invert + p4y * t;
			
			// This curve will become the new 1st half:
			Control1X=p3x;
			Control1Y=p3y;
			
			X=p5x;
			Y=p5y;
			
			path.PathNodeCount++;
			
			// Create the next one:
			QuadLinePoint point=new QuadLinePoint(p2x,p2y);
			
			point.Control1X=p4x;
			point.Control1Y=p4y;
			
			// Insert after this:
			if(Next==null){
				path.LatestPathNode=point;
			}else{
				point.Next=Next;
				Next.Previous=point;
			}
			
			point.Previous=this;
			Next=point;
			
			return point;
		}
Ejemplo n.º 6
0
        public override VectorPoint AddControl(float x, float y, VectorPath path, out int id)
        {
            // Create:
            QuadLinePoint pt = new QuadLinePoint(X, Y);

            pt.Control1X = x;
            pt.Control1Y = y;

            // Remove this and add pt in it's place:
            ReplaceWith(pt, path);

            id = 1;

            return(pt);
        }
		public override VectorPoint Copy(){
			
			QuadLinePoint point=new QuadLinePoint(X,Y);
			point.Length=Length;
			point.NormalX=NormalX;
			point.NormalY=NormalY;
			
			point.Control1X=Control1X;
			point.Control1Y=Control1Y;
			
			point.NormalC1X=NormalC1X;
			point.NormalC1Y=NormalC1Y;
			
			return point;
			
		}
Ejemplo n.º 8
0
        public override VectorPoint DeleteControl(int id, VectorPath path)
        {
            // Create:
            QuadLinePoint pt = new QuadLinePoint(X, Y);

            if (id == 1)
            {
                // Deleting control point 1.
                pt.Control1X = Control2X;
                pt.Control1Y = Control2Y;
            }
            else
            {
                // Deleting control point 2.
                pt.Control1X = Control1X;
                pt.Control1Y = Control1Y;
            }

            // Remove this and add in it's place:
            ReplaceWith(pt, path);

            return(pt);
        }
Ejemplo n.º 9
0
//--------------------------------------