SetMarkers() public method

public SetMarkers ( ) : void
return void
Exemplo n.º 1
0
        public virtual void NextSubpath_Int_Int_Bool() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.CloseFigure ();
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			int start;
			int end;
			bool isClosed;

			int count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (4, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (3, end);
			Assert.IsFalse (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (4, count);
			Assert.AreEqual (4, start);
			Assert.AreEqual (7, end);
			Assert.IsTrue (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (4, count);
			Assert.AreEqual (8, start);
			Assert.AreEqual (11, end);
			Assert.IsTrue (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (2, count);
			Assert.AreEqual (12, start);
			Assert.AreEqual (13, end);
			Assert.IsFalse (isClosed);

			count = iterator.NextSubpath (out start, out end, out isClosed);
			Assert.AreEqual (0, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (0, end);
			Assert.IsTrue (isClosed);
        }
Exemplo n.º 2
0
		public void NextSubpath_NextMarker()
		{
			GraphicsPath path = new GraphicsPath();
			
			path.AddLine (10, 10, 50, 50); // figure #1
			path.AddLine (50, 50, 80, 80);
			path.AddLine (90, 90, 100, 100);
			path.SetMarkers (); // marker #1
			path.AddLine (150, 150, 180, 180);
			path.SetMarkers (); // marker #2
			path.StartFigure (); // figure #2
			path.SetMarkers (); // marker #3 is actually marker #2
			path.AddRectangle (new Rectangle (200, 200, 200, 200)); 
			path.SetMarkers (); // marker #4
			path.AddLine (150, 150, 180, 180); 
			path.StartFigure (); // figure #3
			path.AddBezier (400, 400, 500, 500, 600, 600, 700, 700);
			path.AddBezier (450, 450, 550, 550, 650, 650, 750, 750);

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			int start;
			int end;
			bool isClosed;
			int count = iterator.NextMarker (out start,out end); // marker #1
			Assert.AreEqual (5, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (4, end);

			count = iterator.NextSubpath (out start,out end,out isClosed); // figure #1
			Assert.AreEqual (7, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (6, end);
			Assert.AreEqual (false, isClosed);

			count = iterator.NextMarker (out start,out end); // marker #2 (and #3)
			Assert.AreEqual (2, count);
			Assert.AreEqual (5, start);
			Assert.AreEqual (6, end);

			count = iterator.NextSubpath (out start,out end,out isClosed); // figure #2
			Assert.AreEqual (4, count);
			Assert.AreEqual (7, start);
			Assert.AreEqual (10, end);
			Assert.AreEqual (true, isClosed);

			count = iterator.NextSubpath (out start,out end,out isClosed); // figure #3
			Assert.AreEqual (2, count);
			Assert.AreEqual (11, start);
			Assert.AreEqual (12, end);
			Assert.AreEqual (false, isClosed);

			count = iterator.NextMarker (out start,out end); // marker #5 (end)
			Assert.AreEqual (4, count);
			Assert.AreEqual (7, start);
			Assert.AreEqual (10, end);

			count = iterator.NextMarker (out start,out end); // marker #5 (end)
			Assert.AreEqual (10, count);
			Assert.AreEqual (11, start);
			Assert.AreEqual (20, end);

			// we dont want to be bug compliant with .net
			/*
			count = iterator.NextMarker (out start,out end); // no more markers
			Assert.AreEqual (0, count);
			Assert.AreEqual (11, start);
			Assert.AreEqual (20, end);
			*/

			count = iterator.NextSubpath (out start,out end,out isClosed); // figure #4
			Assert.AreEqual (8, count);
			Assert.AreEqual (13, start);
			Assert.AreEqual (20, end);
			Assert.AreEqual (false, isClosed);

			// we dont want to be bug compliant with .net
			/*
			count = iterator.NextMarker (out start,out end); // no more markers
			Assert.AreEqual (0, count);
			Assert.AreEqual (13, start);
			Assert.AreEqual (20, end);
			*/

			count = iterator.NextSubpath (out start,out end,out isClosed); // no more figures
			Assert.AreEqual (0, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (0, end);
			Assert.AreEqual (true, isClosed);

			count = iterator.NextMarker (out start,out end); // no more markers
			Assert.AreEqual (0, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (0, end);			
		}
Exemplo n.º 3
0
        public virtual void NextMarker_Int32_Int32() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			int start;
			int end;
			int count = iterator.NextMarker (out start, out end);
			Assert.AreEqual (4, count);
			Assert.AreEqual (0, start);
			Assert.AreEqual (3, end);
			
			count = iterator.NextMarker (out start, out end);
			Assert.AreEqual (4, count);
			Assert.AreEqual (4, start);
			Assert.AreEqual (7, end);

			count = iterator.NextMarker (out start, out end);
			Assert.AreEqual (4, count);
			Assert.AreEqual (8, start);
			Assert.AreEqual (11, end);

			count = iterator.NextMarker (out start, out end);
			Assert.AreEqual (2, count);
			Assert.AreEqual (12, start);
			Assert.AreEqual (13, end);

			// FIXME - should return all 0'z?
			/*
			count = iterator.NextMarker (out start, out end);
			Assert.AreEqual (0, count);
			Assert.AreEqual (12, start);
			Assert.AreEqual (13, end);
			*/
        }
Exemplo n.º 4
0
        public virtual void NextPathType() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddBezier( 100, 100, 500, 250, 100, 50, 250, 280);
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			byte pathType;
			int start;
			int end;
			bool isClosed;

			int count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (0, count);
			Assert.AreEqual ((byte)PathPointType.Start, pathType);
			Assert.AreEqual (0, start);
			Assert.AreEqual (0, end);

			iterator.NextSubpath (out start, out end, out isClosed);
			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (3, count);
			Assert.AreEqual ((byte)PathPointType.Line, pathType);
			Assert.AreEqual (0, start);
			Assert.AreEqual (2, end);

			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (4, count);
			Assert.AreEqual ((byte)PathPointType.Bezier3, pathType);
			Assert.AreEqual (2, start);
			Assert.AreEqual (5, end);

			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (3, count);
			Assert.AreEqual ((byte)PathPointType.Line, pathType);
			Assert.AreEqual (5, start);
			Assert.AreEqual (7, end);
			
			// we don't want to be a bug compliant with .net
			/* 
			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (0, count);
			Assert.AreEqual ((byte)PathPointType.Line, pathType);
			Assert.AreEqual (5, start);
			Assert.AreEqual (7, end);
			*/

			iterator.NextSubpath (out start, out end, out isClosed);
			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (4, count);
			Assert.AreEqual ((byte)PathPointType.Bezier3, pathType);
			Assert.AreEqual (8, start);
			Assert.AreEqual (11, end);

			iterator.NextSubpath (out start, out end, out isClosed);
			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (4, count);
			Assert.AreEqual ((byte)PathPointType.Line, pathType);
			Assert.AreEqual (12, start);
			Assert.AreEqual (15, end);

			iterator.NextSubpath (out start, out end, out isClosed);
			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (2, count);
			Assert.AreEqual ((byte)PathPointType.Line, pathType);
			Assert.AreEqual (16, start);
			Assert.AreEqual (17, end);

			iterator.NextSubpath (out start, out end, out isClosed);
			count = iterator.NextPathType (out pathType, out start, out end);
			Assert.AreEqual (0, count);
			Assert.AreEqual ((byte)PathPointType.Line, pathType);
			Assert.AreEqual (0, start);
			Assert.AreEqual (0, end);
        }
Exemplo n.º 5
0
		public void Reverse_Marker ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddRectangle (new Rectangle (200, 201, 60, 61));
				gp.SetMarkers ();
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0, 1, 1, 129 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;

				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 6
0
		public void Clone()
		{
			path = new GraphicsPath ();
			path.AddEllipse (0, 0, 100, 200);
			path.SetMarkers ();
			path.AddLine (new Point (100, 100), new Point (200, 100));
			Rectangle rect = new Rectangle (200, 0, 100, 200);
			path.AddRectangle (rect);
			path.SetMarkers ();
			path.AddLine (new Point (250, 200), new Point (250, 300));
			path.SetMarkers ();

			GraphicsPath cloned = (GraphicsPath) path.Clone ();

			Assert.AreEqual (path.PointCount, cloned.PointCount);

			for ( int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(path.PathPoints [i], cloned.PathPoints [i]);
				Assert.AreEqual (path.PathTypes [i], cloned.PathTypes [i]);
			}

			GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
			pathIterator.Rewind ();

			GraphicsPathIterator clonedIterator = new GraphicsPathIterator(cloned);
			clonedIterator.Rewind ();

			for (int i=0; i < 4; i ++) {
				Assert.AreEqual (pathIterator.NextMarker (path), clonedIterator.NextMarker (cloned));
			}
			//t.AssertCompare ();
		}
Exemplo n.º 7
0
        private void SetMarkers2(Graphics g)
        {
            // Create a path and set two markers.
            GraphicsPath myPath = new GraphicsPath();
            myPath.AddLine(new Point(0, 0), new Point(50, 50));
            myPath.SetMarkers();
            Rectangle rect = new Rectangle(50, 50, 50, 50);
            myPath.AddRectangle(rect);
            myPath.SetMarkers();
            myPath.AddEllipse(100, 100, 100, 50);

            var pathPoints = myPath.PathPoints;
            var pathTypes = myPath.PathTypes;

            Console.WriteLine("SetMarkers Before reverse");
            for (int i = 0; i < myPath.PathTypes.Length; i++)
            {
                Console.WriteLine("{0} - {1},{2}", (PathPointType)pathTypes[i], pathPoints[i].X, pathPoints[i].Y);
            }

            // Draw the path to screen.
            g.FillPath(Brushes.Red, myPath);
            g.DrawPath(new Pen(Color.Black, 2), myPath);

            // Draw the first set of points to the screen.
            DrawPoints2(g, myPath.PathPoints, 20);

            // Call GraphicsPath.Reverse.
            myPath.Reverse();

            pathPoints = myPath.PathPoints;
            pathTypes = myPath.PathTypes;

            Console.WriteLine("SetMarkers After reverse");
            for (int i = 0; i < myPath.PathTypes.Length; i++)
            {
                Console.WriteLine("{0} - {1},{2}", (PathPointType)pathTypes[i], pathPoints[i].X, pathPoints[i].Y);
            }

            // Draw the path to screen.
            g.FillPath(Brushes.CornflowerBlue, myPath);
            g.DrawPath(new Pen(Color.Black, 2), myPath);

            // Draw the reversed set of points to the screen.
            DrawPoints2(g, myPath.PathPoints, 150);
        }
Exemplo n.º 8
0
        public virtual void NextSubpath_GraphicsPath_Bool() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.CloseFigure ();
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);
			GraphicsPath path2 = new GraphicsPath ();

			bool isClosed;

			int count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (4, count);
			Assert.IsFalse (isClosed);

			PointF [] actualPoints = path2.PathPoints;
			byte [] actualTypes = path2.PathTypes;

			PointF [] expectedPoints = new PointF [] {	new PointF(100f, 100f), 
														new PointF(400f, 100f), 
														new PointF(400f, 200f), 
														new PointF(10f, 100f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.PathMarker)};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}

			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (4, count);
			Assert.IsTrue (isClosed);

			actualPoints = path2.PathPoints;
			actualTypes = path2.PathTypes;

			expectedPoints = new PointF [] {new PointF(10f, 10f), 
											new PointF(50f, 250f), 
											new PointF(100f, 5f), 
											new PointF(200f, 280f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			expectedTypes = new byte [] {	(byte) PathPointType.Start, 
								(byte) PathPointType.Bezier3, 
								(byte) PathPointType.Bezier3, 
								(byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker)};
			
			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}

			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (4, count);
			Assert.IsTrue (isClosed);

			actualPoints = path2.PathPoints;
			actualTypes = path2.PathTypes;

			expectedPoints = new PointF [] {new PointF(10f, 20f), 
											new PointF(310f, 20f), 
											new PointF(310f, 420f), 
											new PointF(10f, 420f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			expectedTypes = new byte [] {	(byte) PathPointType.Start, 
											(byte) PathPointType.Line, 
											(byte) PathPointType.Line, 
											(byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker)};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}

			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (2, count);
			Assert.IsFalse (isClosed);

			actualPoints = path2.PathPoints;
			actualTypes = path2.PathTypes;

			expectedPoints = new PointF [] {new PointF(400f, 400f), 
											new PointF(400f, 10f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			expectedTypes = new byte [] {	(byte) PathPointType.Start, 
											(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}

			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (0, count);

			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (0, count);
			Assert.IsTrue (isClosed);
			Assert.AreEqual (2, path2.PointCount);

			actualPoints = path2.PathPoints;
			actualTypes = path2.PathTypes;

			expectedPoints = new PointF [] {new PointF(400f, 400f), 
											new PointF(400f, 10f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			expectedTypes = new byte [] {	(byte) PathPointType.Start, 
											(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}

			path = new GraphicsPath ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			iterator = new GraphicsPathIterator (path);
			
			path2 = new GraphicsPath ();			
			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (4, count);
			Assert.IsFalse (isClosed);
			
			path2 = new GraphicsPath ();
			count = iterator.NextSubpath (path2, out isClosed);
			Assert.AreEqual (0, count);
			Assert.IsTrue (isClosed);
        }
Exemplo n.º 9
0
        private void PathIterator6(Graphics g)
        {
            // Create the GraphicsPath.
            GraphicsPath myPath = new GraphicsPath();
            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };

            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,

            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for drawing the array

            // of points to the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // Draw the set of path points and types to the screen.
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);
            int myStartIndex;
            int myEndIndex;

            // Rewind the Iterator.
            myPathIterator.Rewind();

            // Draw the Markers and their start and end points

            // to the screen.
            j=20;
            for(i=0;i<3;i++)
            {
                myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
                g.DrawString("Marker " + i.ToString() +
                                      ":  Start: " + myStartIndex.ToString()+
                                      "  End: " + myEndIndex.ToString(),
                                      myFont,
                                      myBrush,
                                      200,
                                      j);
                j += 20;
            }

            // Draw the total number of points to the screen.
            j += 20;
            int myPathTotalPoints = myPathIterator.Count;
            g.DrawString("Total Points = " +
                                  myPathTotalPoints.ToString(),
                                  myFont,
                                  myBrush,
                                  200,
                                  j);
        }
Exemplo n.º 10
0
        // End DrawPoints
        private void SetMarkers1(Graphics g)
        {
            // Create a path and set two markers.
            GraphicsPath myPath = new GraphicsPath();
            myPath.AddLine(new Point(0, 0), new Point(50, 50));
            myPath.SetMarkers();
            Rectangle rect = new Rectangle(50, 50, 50, 50);
            myPath.AddRectangle(rect);
            myPath.SetMarkers();
            myPath.AddEllipse(100, 100, 100, 50);

            var pathPoints = myPath.PathPoints;
            var pathTypes = myPath.PathTypes;

            // Draw the path to screen.
            g.DrawPath(new Pen(Color.Black, 2), myPath);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Warps one path to the flattened (<see cref="GraphicsPath.Flatten()"/>) version of another path.
        /// This comes in handy for
        /// <list type="Bullet">
        /// <item>Linestyles that cannot be created with available <see cref="Pen"/>-properties</item>
        /// <item>Warping Text to curves</item>
        /// <item>...</item>
        /// </list>
        /// </summary>
        /// <param name="pathToWarpTo">The path to warp to. This path is flattened before being used, so there is no need to call <see cref="GraphicsPath.Flatten()"/> prior to this function call.</param>
        /// <param name="pathToWarp">The path to warp</param>
        /// <param name="isPattern">Defines whether <paramref name="pathToWarp"/> is a pattern or not. If <paramref name="pathToWarp"/> is a pattern, it is repeated until it has the total length of <see paramref="pathToWarpTo"/></param>
        /// <param name="interval">The interval in which the pattern should be repeated</param>
        /// <returns>Warped <see cref="GraphicsPath"/></returns>
        /// <exception cref="ArgumentNullException">If either pathToWarpTo or pathToWarp is null</exception>
        public static GraphicsPath Warp(GraphicsPath pathToWarpTo, GraphicsPath pathToWarp, bool isPattern, float interval)
        {
            //Test for valid arguments
            if (pathToWarpTo == null)
                throw new ArgumentNullException("pathToWarpTo");
            if (pathToWarp == null)
                throw new ArgumentNullException("pathToWarp");

            //Remove all curves from path to warp to, get total length.
            SortedList<float, GraphSegment> edges;
            pathToWarpTo.Flatten();
            Double pathLength = GetPathLength(pathToWarpTo, out edges);
            if (pathLength == 0)
                return pathToWarp;

            //Prepare path to warp
            pathToWarp = PreparePathToWarp(pathToWarp, isPattern, pathLength, interval);
            if (pathToWarp == null || pathToWarp.PointCount == 0) return null;
            GraphicsPath warpedPath = new GraphicsPath(pathToWarp.FillMode);
            using (GraphicsPathIterator iter = new GraphicsPathIterator(pathToWarp))
            {
                GraphicsPath subPath = new GraphicsPath();
                int currentIndex = 0;
                if (iter.SubpathCount > 1)
                {
                    bool isClosed;
                    while (iter.NextSubpath(subPath, out isClosed) > 0)
                    {
                        GraphicsPath warpedSubPath = WarpSubpath(subPath, edges, ref currentIndex);
                        if (isClosed) warpedSubPath.CloseFigure();
                        warpedPath.AddPath(warpedSubPath, true);
                        warpedPath.SetMarkers();
                    }
                }
                else
                {
                    warpedPath = WarpSubpath(pathToWarp, edges, ref currentIndex);
                }
            }
            return warpedPath;
        }
Exemplo n.º 12
0
		public void SetMarkers()
		{
			path = new GraphicsPath ();
			path.AddEllipse (0, 0, 100, 200);
			path.SetMarkers ();
			path.AddLine (new Point (100, 100), new Point (200, 100));
			Rectangle rect = new Rectangle (200, 0, 100, 200);
			path.AddRectangle (rect);
			path.SetMarkers ();
			path.AddLine (new Point (250, 200), new Point (250, 300));
			path.SetMarkers ();

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) (PathPointType.Bezier3 | PathPointType.CloseSubpath | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) (PathPointType.Line | PathPointType.PathMarker) };

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
			}	


			//t.AssertCompare ();
		}
Exemplo n.º 13
0
		public void Reverse2()
		{
			path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.SetMarkers ();
			path.AddLine (new Point (400, 200), new Point (10, 100));

			path.SetMarkers ();
			path.StartFigure ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.SetMarkers ();
			path.StartFigure ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));

			path.StartFigure ();
			path.AddLine (new Point (400, 400), new Point (400, 10));
			path.AddBezier( 100, 100, 500, 250, 150, 500, 250, 300);
			path.SetMarkers ();
			path.AddLine (new Point (400, 450), new Point (500, 510));
			path.SetMarkers ();
			path.CloseFigure ();

			path.Reverse ();

			PointF [] expectedPoints = new PointF [] {	new PointF(500f, 510f), 
														new PointF(400f, 450f), 
														new PointF(250f, 300f), 
														new PointF(150f, 500f), 
														new PointF(500f, 250f), 
														new PointF(100f, 100f), 
														new PointF(400f, 10f), 
														new PointF(400f, 400f), 
														new PointF(10f, 420f), 
														new PointF(310f, 420f), 
														new PointF(310f, 20f), 
														new PointF(10f, 20f), 
														new PointF(200f, 280f), 
														new PointF(100f, 5f), 
														new PointF(50f, 250f), 
														new PointF(10f, 10f), 
														new PointF(10f, 100f), 
														new PointF(400f, 200f), 
														new PointF(400f, 100f), 
														new PointF(100f, 100f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) (PathPointType.Line | PathPointType.PathMarker), 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Bezier3, 
													(byte) PathPointType.Bezier3, 
													(byte) (PathPointType.Bezier3 | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) (PathPointType.Line | PathPointType.PathMarker),
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], path.PathTypes [i]);
			}	
			
			//t.AssertCompare ();
		}
Exemplo n.º 14
0
        public virtual void NextMarker_GraphicsPath() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPath path2 = new GraphicsPath ();
			path.AddLine (new Point (150, 150), new Point (450, 150));
			path.AddLine (new Point (450, 250), new Point (50, 150));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			iterator.NextMarker (null);
			iterator.NextMarker (path2);

			Assert.AreEqual (4, path2.PointCount);
			PointF [] actualPoints = path2.PathPoints;
			byte [] actualTypes = path2.PathTypes;

			PointF [] expectedPoints = new PointF [] {	new PointF(100f, 100f), 
														new PointF(400f, 100f), 
														new PointF(400f, 200f), 
														new PointF(10f, 100f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.PathMarker)};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}

			iterator.NextMarker (null);
			iterator.NextMarker (null);
			iterator.NextMarker (null);
			iterator.NextMarker (path2);

			Assert.AreEqual (4, path2.PointCount);
			actualPoints = path2.PathPoints;
			actualTypes = path2.PathTypes;

			expectedPoints = new PointF [] {new PointF(10f, 10f), 
											new PointF(50f, 250f), 
											new PointF(100f, 5f), 
											new PointF(200f, 280f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			expectedTypes = new byte [] {	(byte) PathPointType.Start, 
												(byte) PathPointType.Bezier3, 
												(byte) PathPointType.Bezier3, 
												(byte) (PathPointType.Bezier3 | PathPointType.PathMarker)};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}	
			
        }
Exemplo n.º 15
0
        public void PathIterator1(Graphics g)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath ();

            // Set up a points array.
            Point[] myPoints = {
                new Point(20, 20),
                new Point(120, 120),
                new Point(20, 120),
                new Point(20, 20)
            };

            // Create a rectangle.
            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add the points, rectangle, and an ellipse to the path.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path, and arrays of
            // the  points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing the array of points on the left
            // side of the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the set of points and types and types to the left side
            // of the screen.
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator for myPath and rewind it.
            GraphicsPathIterator myPathIterator =
                new GraphicsPathIterator(myPath);
            myPathIterator.Rewind();

            // Set up the arrays to receive the copied data.
            PointF[] points = new PointF[myPathIterator.Count];
            byte[] types = new byte[myPathIterator.Count];
            int myStartIndex;
            int myEndIndex;

            // Increment the starting index to the second marker in the
            // path.
            myPathIterator.NextMarker(out myStartIndex, out myEndIndex);
            myPathIterator.NextMarker(out myStartIndex, out myEndIndex);

            // Copy all the points and types from the starting index to the
            // ending index to the points array and the types array
            // respectively.
            int numPointsCopied = myPathIterator.CopyData(
                ref points,
                ref types,
                myStartIndex,
                myEndIndex);

            // List the copied points to the right side of the screen.
            j = 20;
            int copiedStartIndex = 0;
            for(i=0; i<numPointsCopied; i++)
            {
                copiedStartIndex = myStartIndex + i;
                g.DrawString(
                    "Point: " + copiedStartIndex.ToString() +
                    ", Value: " + points[i].ToString() +
                    ", Type: " + types[i].ToString(),
                    myFont,
                    myBrush,
                    200,
                    j);
                j+=20;
            }
        }
Exemplo n.º 16
0
        public virtual void Rewind() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator iterator = new GraphicsPathIterator (path);

			int i;
			int j;
			iterator.NextMarker (out i, out j);
			iterator.NextMarker (out i, out j);

			iterator.Rewind ();
			iterator.NextMarker (out i, out j);

			Assert.AreEqual (0, i);
			Assert.AreEqual (3, j);
        }
Exemplo n.º 17
0
        public void PathIterator5(Graphics g)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath();

            // Set up primitives to add to myPath.
            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };

            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,
            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing all the values of the path's
            // points to the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the values for all of path points and types to
            // the left side of the screen.
            for(i=0; i < myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),  myFont, myBrush,
                                      20, j);

                j+=20;

            }

            // Create a GraphicsPathIterator.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);

            // Rewind the iterator.
            myPathIterator.Rewind();

            // Create a GraphicsPath to receive a section of myPath.
            GraphicsPath myPathSection = new GraphicsPath();

            // Retrieve and list the number of points contained in

            // the first marker to the right side of the screen.
            int markerPoints;
            markerPoints = myPathIterator.NextMarker(myPathSection);
            g.DrawString("Marker: 1" + "  Num Points: " +
                                  markerPoints.ToString(),  myFont, myBrush, 200, 20);
        }
Exemplo n.º 18
0
        public virtual void CopyData() 
		{
            GraphicsPath path = new GraphicsPath ();
			path.AddLine (new Point (100, 100), new Point (400, 100));
			path.AddLine (new Point (400, 200), new Point (10, 100));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddRectangle (new Rectangle (10, 20, 300, 400));
			path.StartFigure ();
			path.SetMarkers ();
			path.AddLine (new Point (400, 400), new Point (400, 10));

			GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
			pathIterator.Rewind ();
			PointF [] actualPoints = new PointF [10];
			byte [] actualTypes = new byte [10];
			pathIterator.CopyData (ref actualPoints, ref actualTypes, 0, 9);

			PointF [] expectedPoints = new PointF [] {	new PointF(100f, 100f), 
														new PointF(400f, 100f), 
														new PointF(400f, 200f), 
														new PointF(10f, 100f), 
														new PointF(10f, 20f), 
														new PointF(310f, 20f), 
														new PointF(310f, 420f), 
														new PointF(10f, 420f), 
														new PointF(400f, 400f), 
														new PointF(400f, 10f)};
			
			for(int i = 0; i < expectedPoints.Length; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], actualPoints [i]);
			}

			byte [] expectedTypes = new byte [] {	(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line, 
													(byte) PathPointType.Line, 
													(byte) (PathPointType.Line | PathPointType.CloseSubpath | PathPointType.PathMarker), 
													(byte) PathPointType.Start, 
													(byte) PathPointType.Line};

			for (int i=0; i < expectedTypes.Length; i++) {
				Assert.AreEqual (expectedTypes [i], actualTypes [i]);
			}	
        }
Exemplo n.º 19
0
        public void PathIterator7(Graphics g)
        {
            // Create a graphics path.
            GraphicsPath myPath = new GraphicsPath();

            // Set up primitives to add to myPath.
            Point[] myPoints = {new Point(20, 20), new Point(120, 120),
                new Point(20, 120),new Point(20, 20) };
            Rectangle myRect = new Rectangle(120, 120, 100, 100);

            // Add 3 lines, a rectangle, an ellipse, and 2 markers.
            myPath.AddLines(myPoints);
            myPath.SetMarkers();
            myPath.AddRectangle(myRect);
            myPath.SetMarkers();
            myPath.AddEllipse(220, 220, 100, 100);

            // Get the total number of points for the path,

            // and the arrays of the points and types.
            int myPathPointCount = myPath.PointCount;
            PointF[] myPathPoints = myPath.PathPoints;
            byte[] myPathTypes = myPath.PathTypes;

            // Set up variables for listing all of the path's

            // points to the screen.
            int i;
            float j = 20;
            Font myFont = new Font("Arial", 8);
            SolidBrush myBrush = new SolidBrush(Color.Black);

            // List the values of all the path points and types to the screen.
            for(i=0; i<myPathPointCount; i++)
            {
                g.DrawString(myPathPoints[i].X.ToString()+
                                      ", " + myPathPoints[i].Y.ToString() + ", " +
                                      myPathTypes[i].ToString(),
                                      myFont,
                                      myBrush,
                                      20,
                                      j);
                j+=20;
            }

            // Create a GraphicsPathIterator for myPath.
            GraphicsPathIterator myPathIterator = new
                GraphicsPathIterator(myPath);

            // Rewind the iterator.
            myPathIterator.Rewind();

            // Create the GraphicsPath section.
            GraphicsPath myPathSection = new GraphicsPath();

            // Iterate to the 3rd subpath and list the number of points therein

            // to the screen.
            int subpathPoints;
            bool IsClosed2;

            // Iterate to the third subpath.
            subpathPoints = myPathIterator.NextSubpath(
                myPathSection, out IsClosed2);
            subpathPoints = myPathIterator.NextSubpath(
                myPathSection, out IsClosed2);
            subpathPoints = myPathIterator.NextSubpath(
                myPathSection, out IsClosed2);

            // Write the number of subpath points to the screen.
            g.DrawString("Subpath: 3"  +
                                  "   Num Points: " +
                                  subpathPoints.ToString(),
                                  myFont,
                                  myBrush,
                                  200,
                                  20);
        }
Exemplo n.º 20
0
		public void Reverse_Subpath_Marker_2 ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLine (0, 1, 2, 3);
				gp.SetMarkers ();
				gp.StartFigure ();
				gp.AddLine (20, 21, 22, 23);
				gp.AddBezier (5, 6, 7, 8, 9, 10, 11, 12);
				PointF[] bp = gp.PathPoints;
				byte[] expected = new byte[] { 0, 3, 3, 3, 1, 33, 0, 1 };

				gp.Reverse ();
				PointF[] ap = gp.PathPoints;
				byte[] at = gp.PathTypes;

				int count = gp.PointCount;
				Assert.AreEqual (bp.Length, count, "PointCount");
				for (int i = 0; i < count; i++) {
					Assert.AreEqual (bp[i], ap[count - i - 1], "Point" + i.ToString ());
					Assert.AreEqual (expected[i], at[i], "Type" + i.ToString ());
				}
			}
		}
Exemplo n.º 21
0
		public void ClearMarkers()
		{
			path = new GraphicsPath ();
			path.AddEllipse (0, 0, 100, 200);
			path.SetMarkers ();
			path.AddLine (new Point (100, 100), new Point (200, 100));
			Rectangle rect = new Rectangle (200, 0, 100, 200);
			path.AddRectangle (rect);
			path.SetMarkers ();
			path.AddLine (new Point (250, 200), new Point (250, 300));
			path.SetMarkers ();

			path.ClearMarkers();

			GraphicsPathIterator pathIterator = new GraphicsPathIterator(path);
			pathIterator.Rewind ();
			int [] pointsNumber = new int [] {21, 0, 0, 0};
			for (int i=0; i < 4; i ++) {
				Assert.AreEqual (pointsNumber [i], pathIterator.NextMarker (path));
			}
			//t.AssertCompare ();
		}