當前位置: 首頁>>代碼示例>>C#>>正文


C# PointF.Add方法代碼示例

本文整理匯總了C#中System.Drawing.PointF.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# PointF.Add方法的具體用法?C# PointF.Add怎麽用?C# PointF.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.PointF的用法示例。


在下文中一共展示了PointF.Add方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Move

        public Point Move(IField field)
        {
            var velocity = 0f;
            lock(velocityLock)
                velocity = Velocity;
            var location = new PointF(Location.X, Location.Y);
            velocity *= field.Time.TimeStep / field.Time.Interval;
            var vecV = Direction.Multiply(velocity);
            var step = field.Time.TimeStep;
            var endTime = field.Time.Interval + field.Time.TimeStep;
            var rectangles = field.StaticObjBoundaries;

            for (var time = 0f; time < endTime; time += step)
            {
                location = location.Add(vecV);
                var curLocRect = new RectangleF(location, Size);
                foreach (var rect in rectangles)
                    if (curLocRect.IntersectsWith(rect))
                    {
                        var intersectRect = RectangleF.Intersect(curLocRect, rect);//.Location;
                        var normal = GetNormal(intersectRect, rect);
                        var negDir = Direction.Negate();
                        Direction = negDir.Reflect(location, normal).Normalize();
                        vecV = Direction.Multiply(velocity);
                        location = location.Add(vecV);
                        curLocRect = new RectangleF(location, Size);
                        while (curLocRect.IntersectsWith(rect))
                        {
                            location = location.Add(vecV);
                            curLocRect = new RectangleF(location, Size);
                        }
                        break;
                    }
            }
            return location.ToPoint();
        }
開發者ID:efgefg0001,項目名稱:Tanks,代碼行數:36,代碼來源:Tank.cs

示例2: GetFlamePoints

        private PointF[] GetFlamePoints(int offsetX, int offsetY)
        {
            var center = new PointF(_position.X - offsetX, _position.Y - offsetY);
            var front = new PointF((float)Math.Cos(_rotation + Math.PI) * ShipSize * 1.5f, (float)Math.Sin(_rotation + Math.PI) * ShipSize * 1.5f);
            var left = new PointF((float)Math.Cos(_rotation + Theta + 0.3f) * ShipSize, (float)Math.Sin(_rotation + Theta + 0.3f) * ShipSize);
            var right = new PointF((float)Math.Cos(_rotation - Theta - 0.3f) * ShipSize, (float)Math.Sin(_rotation - Theta - 0.3f) * ShipSize);

            return new[] { center.Add(front), center.Add(left), center.Add(right) };
        }
開發者ID:khyperia,項目名稱:Spacerunner2,代碼行數:9,代碼來源:Player.cs

示例3: SetCenter

		/// <summary>
		/// Set Center of a Rectangle
		/// </summary>
		/// <param name="r"></param>
		/// <param name="p"></param>
		/// <returns></returns>
		public static RectangleF SetCenter(this RectangleF r, PointF p)
		{
			p = p.Add(r.Size.Multiply(-0.5f));
			r.Location = p;
			return r;
		}
開發者ID:ramoneeza,項目名稱:RopHelperSnippets,代碼行數:12,代碼來源:Rop.Helper.Geom.cs

示例4: SetAnchor

		/// <summary>
		/// Set Anchor position of a Rectangle (No Resize)
		/// </summary>
		/// <param name="r">Rectangle</param>
		/// <param name="a">Anchor Index</param>
		/// <param name="p">New Position of Anchor</param>
		/// <returns></returns>
		public static RectangleF SetAnchor(this RectangleF r, int a, PointF p)
		{
			var sz = r.Size;
			var l = r.Location;
			switch (a)
			{
				case 0: l = p; break;
				case 1: l = new PointF(p.X - sz.Width, p.Y); break;
				case 2: l = new PointF(p.X, p.Y - sz.Height); break;
				case 3: l = new PointF(p.X - sz.Width, p.Y - sz.Height); break;
				case 4: l = p.Add(sz.Multiply(-0.5f)); break;
			}
			return new RectangleF(l, sz);
		}
開發者ID:ramoneeza,項目名稱:RopHelperSnippets,代碼行數:21,代碼來源:Rop.Helper.Geom.cs

示例5: Center

		/// <summary>
		/// Center between two points
		/// </summary>
		/// <param name="p1"></param>
		/// <param name="p2"></param>
		/// <returns></returns>
		public static PointF Center(PointF p1, PointF p2) => p2.Add(p1).Scale(0.5f);
開發者ID:ramoneeza,項目名稱:RopHelperSnippets,代碼行數:7,代碼來源:Rop.Helper.Geom.cs

示例6: FromCornerSize

 public static Rectangle FromCornerSize(PointF TopLeftCorner, PointF Size)
 {
     return new Rectangle(new Line(TopLeftCorner, TopLeftCorner.Add(Size)));
 }
開發者ID:Shayan-To,項目名稱:OpenMesh,代碼行數:4,代碼來源:Rectangle.cs

示例7: FromCenterSize

 public static Rectangle FromCenterSize(PointF Center, PointF Size)
 {
     Size = Size.Divide(2);
     return new Rectangle(new Line(Center.Subtract(Size), Center.Add(Size)));
 }
開發者ID:Shayan-To,項目名稱:OpenMesh,代碼行數:5,代碼來源:Rectangle.cs


注:本文中的System.Drawing.PointF.Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。