当前位置: 首页>>代码示例>>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;未经允许,请勿转载。