AddClosedCurve() public method

public AddClosedCurve ( Point points ) : void
points Point
return void
        public static bool IsPointInsideRegion(Bitmap bitmap, System.Drawing.Point P1, System.Drawing.Point P2, System.Drawing.Point P3, System.Drawing.Point P4, System.Drawing.Point Px)
        {
            try
            {
                Bitmap   bmp  = new Bitmap(bitmap.Size.Width, bitmap.Size.Height);
                Graphics grph = Graphics.FromImage(bmp);

                System.Drawing.Point[] pointsArray = { P1, P2, P3, P4 };

                System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();

                path.AddClosedCurve(pointsArray);

                Region pathRegion = new Region(path);

                if (pathRegion.IsVisible(Px, grph))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ex = new Exception("Error occurred while identifying if point lies inside the quadrilateral or not. " + ex.Message);
                throw ex;
            }
        }
Exemplo n.º 2
0
        public override RectangleF ReturnBounds()
        {
            Point[] points = (Point[])pointsList.ToArray(typeof(Point));
            GraphicsPath path = new GraphicsPath();
            path.AddClosedCurve(points, 1);

            path.Transform(this.TMatrix.TransformationMatrix);
            return path.GetBounds();
        }
 public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath path)
 {
     if (pts != null)
     {
         if (pts.Length > 2)
         {
             path.AddClosedCurve(pts);
         }
     }
 }
Exemplo n.º 4
0
        protected override void UpdatePath()
        {
            if (this.Points == null || this.Points.Length == 0) return;

            InternalPath = new GraphicsPath();
            InternalPath.AddClosedCurve(this.Points);

            Matrix mtx = new Matrix();
            mtx.RotateAt(this.Rotation, InternalRotationBasePoint);
            InternalPath.Transform(mtx);
        }
Exemplo n.º 5
0
 private void Type(Control sender, int p_1, double p_2)
 {
     GraphicsPath oPath = new GraphicsPath();
     oPath.AddClosedCurve(new Point[] { new Point(0, sender.Height / p_1),
         new Point(sender.Width / p_1, 0),
         new Point(sender.Width - sender.Width / p_1, 0), 
         new Point(sender.Width, sender.Height / p_1), 
         new Point(sender.Width, sender.Height - sender.Height / p_1),
         new Point(sender.Width - sender.Width / p_1, sender.Height),
         new Point(sender.Width / p_1, sender.Height),
         new Point(0, sender.Height - sender.Height / p_1) }, (float)p_2);
     sender.Region = new Region(oPath);
 }
Exemplo n.º 6
0
        public override void DrawYourSelf(Graphics graphics)
        {
            if (pointsList.Count < 4) return;
            Point[] points = (Point[])pointsList.ToArray(typeof(Point));

            GraphicsPath path = new GraphicsPath();
            path.AddClosedCurve(points, 1);
            path.Transform(this.TMatrix.TransformationMatrix);

            Pen pen = new Pen(this.BorderColor, this.BorderWidth);
            if (IS_FILLED)
            {
                SolidBrush brush = new SolidBrush(this.FillColor);
                graphics.FillPath(brush, path);
            }
            graphics.DrawPath(pen, path);

            if (this.Selected)
            {
                this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
                this.selectionUnit.DrawYourSelf(graphics);
            }
        }
Exemplo n.º 7
0
		public void AddClosedCurve_Point_2 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
		}
Exemplo n.º 8
0
		static private GraphicsPath ClosedCurve ()
		{
			GraphicsPath path = new GraphicsPath ();
			path.AddClosedCurve (new Point[4] { 
				new Point (20, 100), new Point (70, 10),
				new Point (130, 200), new Point (180, 100)
				});
			return path;
		}
Exemplo n.º 9
0
		public void AddClosedCurve_Point_1 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new Point[1] { new Point (1, 1) });
		}
Exemplo n.º 10
0
		/// <summary>
		/// Performs a hit test on the <see cref="Graphic"/> at a given point.
		/// </summary>
		/// <param name="point">The mouse position in destination coordinates.</param>
		/// <returns>
		/// <b>True</b> if <paramref name="point"/> "hits" the <see cref="Graphic"/>,
		/// <b>false</b> otherwise.
		/// </returns>
		public override bool HitTest(Point point)
		{
			base.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				PointF[] pathPoints = GetCurvePoints(_points);
				GraphicsPath gp = new GraphicsPath();
				if (_points.IsClosed)
					gp.AddClosedCurve(pathPoints);
				else
					gp.AddCurve(pathPoints);
				return gp.IsVisible(point);
			}
			finally
			{
				base.ResetCoordinateSystem();
			}
		}
Exemplo n.º 11
0
        private void AddClosedCurve1(Graphics g)
        {
            // Creates a symetrical, closed curve.
            Point[] myArray =
            {
                new Point(20,100),
                new Point(40,150),
                new Point(60,125),
                new Point(40,100),
                new Point(60,75),
                new Point(40,50)
            };

            // Create a new path and add curve.
            GraphicsPath myPath = new GraphicsPath();
            myPath.AddClosedCurve(myArray, 0.5f);
            Pen myPen = new Pen(Color.Black, 2);

            // Draw the path to screen.
            g.DrawPath(myPen, myPath);
        }
Exemplo n.º 12
0
		public void StartClose_AddClosedCurve ()
		{
			GraphicsPath path = new GraphicsPath ();
			path.AddLine (1, 1, 2, 2);
			path.AddClosedCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
			path.AddLine (10, 10, 20, 20);
			byte[] types = path.PathTypes;
			// check first types
			Assert.AreEqual (0, types[0], "start/Line");
			Assert.AreEqual (0, types[2], "start/ClosedCurve");
			// check last types
			Assert.AreEqual (131, types[path.PointCount - 3], "end/ClosedCurve");
			Assert.AreEqual (0, types[path.PointCount - 2], "start/Line3");
			Assert.AreEqual (1, types[path.PointCount - 1], "end/Line3");
		}
Exemplo n.º 13
0
		public void AddClosedCurve_PointFArr()
		{
			PointF [] points = new PointF [] {	new PointF(20.01f, 100.1f),
												new PointF(40.02f, 75.2f),
												new PointF(60.03f, 125.3f),
												new PointF(80.04f, 100.4f),
												new PointF(100.05f, 50.5f),
												new PointF(120.06f, 150.6f),
												new PointF(140.07f, 100.7f)};

			path = new GraphicsPath();
			path.AddClosedCurve(points);

			Assert.AreEqual (22, path.PointCount);

			PointF [] expectedPoints = new PointF [] {	new PointF(20.01f, 100.1f), 
														new PointF(3.334998f, 95.84999f), 
														new PointF(33.35f, 70.99999f), 
														new PointF(40.02f, 75.2f), 
														new PointF(46.69f, 79.39999f), 
														new PointF(53.36f, 121.1f), 
														new PointF(60.03f, 125.3f), 
														new PointF(66.7f, 129.5f), 
														new PointF(73.37f, 112.8667f), 
														new PointF(80.04f, 100.4f), 
														new PointF(86.71f, 87.93333f), 
														new PointF(93.38f, 42.13333f), 
														new PointF(100.05f, 50.5f), 
														new PointF(106.72f, 58.86666f), 
														new PointF(113.39f, 142.2333f), 
														new PointF(120.06f, 150.6f), 
														new PointF(126.73f, 158.9667f), 
														new PointF(156.745f, 109.1167f), 
														new PointF(140.07f, 100.7f), 
														new PointF(123.395f, 92.28333f), 
														new PointF(36.685f, 104.35f), 
														new PointF(20.01f, 100.1f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			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, 
													(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.Bezier | PathPointType.CloseSubpath)};

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

			t.Graphics.DrawPath (p, path);
			t.Show ();
			//t.AssertCompare ();
		}
Exemplo n.º 14
0
		public void AddClosedCurve_PointF_3 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
			CheckClosedCurve (gp);
		}
Exemplo n.º 15
0
		public void GetBounds_Empty_ClosedCurve ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new Point[4] { new Point (20, 100), new Point (70, 10),
				new Point (130, 200), new Point (180, 100) });
#if false
			// so far from reality that it's totally useless
			Assert.AreEqual (1.666666f, rect.X, 0.00001, "Bounds.X");
			Assert.AreEqual (-6.66666f, rect.Y, 1, "Bounds.Y");
			Assert.AreEqual (196.6666f, rect.Width, 1, "Bounds.Width");
			Assert.AreEqual (221.6666f, rect.Height, 1, "Bounds.Height");
#endif
			gp.Dispose ();
		}
Exemplo n.º 16
0
		public void AddClosedCurve_Point_3 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
			CheckClosedCurve (gp);
		}
Exemplo n.º 17
0
		public void AddClosedCurve_PointF_1 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new PointF[1] { new PointF (1f, 1f) });
		}
Exemplo n.º 18
0
		public void AddClosedCurve_PointArr_Float()
		{
			Point [] points = new Point [] {new Point(20, 100),
											new Point(40, 75),
											new Point(60, 125),
											new Point(80, 100),
											new Point(100, 50),
											new Point(120, 150),
											new Point(140, 100)};

			path = new GraphicsPath();
			path.AddClosedCurve(points, 0.9f);

			Assert.AreEqual (22, path.PointCount);

			PointF [] expectedPoints = new PointF [] {	new PointF(20f, 100f), 
														new PointF(-10f, 92.49999f), 
														new PointF(28f, 67.49999f), 
														new PointF(40f, 75f), 
														new PointF(52f, 82.5f), 
														new PointF(48f, 117.5f), 
														new PointF(60f, 125f), 
														new PointF(72f, 132.5f), 
														new PointF(67.99999f, 122.5f), 
														new PointF(80f, 100f), 
														new PointF(92f, 77.49999f), 
														new PointF(87.99999f, 35f), 
														new PointF(100f, 50f), 
														new PointF(112f, 65f), 
														new PointF(108f, 135f), 
														new PointF(120f, 150f), 
														new PointF(132f, 165f), 
														new PointF(170f, 115f), 
														new PointF(140f, 100f), 
														new PointF(110f, 84.99999f), 
														new PointF(50f, 107.5f), 
														new PointF(20f, 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.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, 
													(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.Bezier | PathPointType.CloseSubpath)};

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

			t.Graphics.DrawPath (p, path);
			t.Show ();
			//t.AssertCompare ();
		}
Exemplo n.º 19
0
		/// <summary>
		/// Performs a hit test on the <see cref="Graphic"/> at a given point.
		/// </summary>
		/// <param name="point">The mouse position in destination coordinates.</param>
		/// <returns>
		/// <b>True</b> if <paramref name="point"/> "hits" the <see cref="Graphic"/>,
		/// <b>false</b> otherwise.
		/// </returns>
		public override bool HitTest(Point point)
		{
			base.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				using (var gp = new GraphicsPath())
				using (var pen = new Pen(Color.Black, HitTestDistance))
				{
					PointF[] pathPoints = GetCurvePoints(_points);
					if (_points.IsClosed)
						gp.AddClosedCurve(pathPoints);
					else
						gp.AddCurve(pathPoints);
					return gp.IsOutlineVisible(point, pen);
				}
			}
			finally
			{
				base.ResetCoordinateSystem();
			}
		}
Exemplo n.º 20
0
			public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel)
			{
				if (gripLevel <= 1)
				{
					ClosedCardinalSpline ls = (ClosedCardinalSpline)_hitobject;
					PointF[] pts = new PointF[ls._curvePoints.Count];
					var offset = ls.Location.AbsoluteVectorPivotToLeftUpper;
					for (int i = 0; i < pts.Length; i++)
					{
						pts[i] = (PointF)(ls._curvePoints[i] + offset);
						var pt = ls._transformation.TransformPoint(pts[i]);
						pt = this.Transformation.TransformPoint(pt);
						pts[i] = pt;
					}

					IGripManipulationHandle[] grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 1 + ls._curvePoints.Count];

					// Translation grips
					GraphicsPath path = new GraphicsPath();
					path.AddClosedCurve(pts, (float)ls._tension);
					path.Widen(new Pen(Color.Black, (float)(6 / pageScale)));
					grips[grips.Length - 1] = new MovementGripHandle(this, path, null);

					// PathNode grips
					if (gripLevel == 1)
					{
						float gripRadius = (float)(3 / pageScale);
						for (int i = 0; i < ls._curvePoints.Count; i++)
						{
							grips[i] = new ClosedCardinalSplinePathNodeGripHandle(this, i, pts[i], gripRadius);
						}
					}
					return grips;
				}
				else
				{
					return base.GetGrips(pageScale, gripLevel);
				}
			}
Exemplo n.º 21
0
		private GraphicsPath InternalGetPath(PointD2D offset)
		{
			GraphicsPath gp = new GraphicsPath();

			PointF[] pt = new PointF[_curvePoints.Count];
			for (int i = 0; i < _curvePoints.Count; i++)
				pt[i] = new PointF((float)(_curvePoints[i].X + offset.X), (float)(_curvePoints[i].Y + offset.Y));
			gp.AddClosedCurve(pt, (float)_tension);
			return gp;
		}
Exemplo n.º 22
0
		public void AddClosedCurve_PointFArr_Float()
		{
			PointF [] points = new PointF [] {	new PointF(20.01f, 100.1f),
												new PointF(40.02f, 75.2f),
												new PointF(60.03f, 125.3f),
												new PointF(80.04f, 100.4f),
												new PointF(100.05f, 50.5f),
												new PointF(120.06f, 150.6f),
												new PointF(140.07f, 100.7f)};

			path = new GraphicsPath();
			path.AddClosedCurve(points, 0.8f);

			Assert.AreEqual (22, path.PointCount);

			PointF [] expectedPoints = new PointF [] {	new PointF(20.01f, 100.1f), 
														new PointF(-6.670003f, 93.3f), 
														new PointF(29.348f, 68.47999f), 
														new PointF(40.02f, 75.2f), 
														new PointF(50.692f, 81.92f), 
														new PointF(49.358f, 118.58f), 
														new PointF(60.03f, 125.3f), 
														new PointF(70.702f, 132.02f), 
														new PointF(69.368f, 120.3467f), 
														new PointF(80.04f, 100.4f), 
														new PointF(90.712f, 80.45333f), 
														new PointF(89.378f, 37.11333f), 
														new PointF(100.05f, 50.5f), 
														new PointF(110.722f, 63.88667f), 
														new PointF(109.388f, 137.2133f), 
														new PointF(120.06f, 150.6f), 
														new PointF(130.732f, 163.9867f), 
														new PointF(166.75f, 114.1667f), 
														new PointF(140.07f, 100.7f), 
														new PointF(113.39f, 87.23332f), 
														new PointF(46.69f, 106.9f), 
														new PointF(20.01f, 100.1f)};
			
			for(int i = 0; i < path.PointCount; i++) {
				DrawingTest.AssertAlmostEqual(expectedPoints [i], path.PathPoints [i]);
			}

			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, 
													(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.Bezier | PathPointType.CloseSubpath)};

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

			t.Graphics.DrawPath (p, path);
			t.Show ();
			//t.AssertCompare ();
		}
Exemplo n.º 23
0
		public void AddClosedCurve_PointF_0 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new PointF[0]);
		}
Exemplo n.º 24
0
 /// <summary>
 /// Vytvoří 2D cestu pro vykreslení
 /// </summary>
 /// <returns></returns>
 public GraphicsPath MakePath()
 {
     GraphicsPath Ret = new GraphicsPath();
     Ret.AddClosedCurve(ObjectGeometry, Tension);
     return Ret;
 }
Exemplo n.º 25
0
		public void AddClosedCurve_PointF_2 ()
		{
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
		}
Exemplo n.º 26
0
 public void DrawClosedCurve(Pen pen, PointF[] points)
 {
     using (var path = new GraphicsPath())
     {
         path.AddClosedCurve(points);
         DrawPath(pen, path);
     }
 }
Exemplo n.º 27
0
		public void AddClosedCurve_SamePointF ()
		{
			PointF [] points = new PointF [3] { new PointF (1f, 1f), new PointF (1f, 1f), new PointF (1f, 1f) };
			GraphicsPath gp = new GraphicsPath ();
			gp.AddClosedCurve (points);
			Assert.AreEqual (10, gp.PointCount, "1-PointCount");
			gp.AddClosedCurve (points);
			Assert.AreEqual (20, gp.PointCount, "2-PointCount");
		}
Exemplo n.º 28
0
 public void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode)
 {
     using (var path = new GraphicsPath())
     {
         path.AddClosedCurve(points, tension);
         path.FillMode = fillmode;
         DrawPath(pen, path);
     }
 }
Exemplo n.º 29
0
		public void Flatten_ClosedCurve ()
		{
			GraphicsPath path = new GraphicsPath ();
			path.AddClosedCurve (new Point[4] { 
				new Point (0, 0), new Point (40, 20),
				new Point (20, 40), new Point (40, 40)
				});
			GraphicsPath clone = (GraphicsPath) path.Clone ();
			path.Flatten ();
			CompareFlats (path, clone);
		}
Exemplo n.º 30
0
 public void FillClosedCurve(Brush brush, PointF[] points)
 {
     using (var path = new GraphicsPath())
     {
         path.AddClosedCurve(points);
         FillPath(brush, path);
     }
 }
Exemplo n.º 31
0
		public void Reverse_ClosedCurve ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				Point[] beziers = new Point[] { new Point (1,2), new Point (3,4), new Point (5,6),
					new Point (7,8), new Point (9,10), new Point (11,12), new Point (13,14) };
				gp.AddClosedCurve (beziers);
				Reverse (gp);
			}
		}
Exemplo n.º 32
0
 public void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension)
 {
     using (var path = new GraphicsPath())
     {
         path.AddClosedCurve(points, tension);
         path.FillMode = fillmode;
         FillPath(brush, path);
     }
 }