本文整理汇总了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();
}
示例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) };
}
示例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;
}
示例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);
}
示例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);
示例6: FromCornerSize
public static Rectangle FromCornerSize(PointF TopLeftCorner, PointF Size)
{
return new Rectangle(new Line(TopLeftCorner, TopLeftCorner.Add(Size)));
}
示例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)));
}