本文整理汇总了C#中Point.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Point.Clone方法的具体用法?C# Point.Clone怎么用?C# Point.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.Clone方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Point
public void Point()
{
//Do various Point method calls to cover the point class with sufficient testing
Point p0 = new Point();
Point p1 = new Point(0, 0);
Point p2 = new Point(450, 120);
Assert.IsTrue(p0.IsEmpty());
Assert.IsFalse(p1.IsEmpty());
Assert.AreNotEqual(p0, p1);
Assert.AreEqual(450, p2.X);
Assert.AreEqual(120, p2.Y);
Assert.AreNotSame(p2.Clone(), p2);
p0 = p2.Clone();
p0.X += 100;
p0.Y = 150;
p0[0] += p0[1];
Assert.AreEqual(new Point(700, 150), p0);
Assert.AreEqual(p2, p2.GetBoundingBox().Min);
Assert.AreEqual(p2, p2.GetBoundingBox().Max);
Assert.IsTrue(p2.IsSimple());
Assert.IsFalse(p2.IsEmpty());
Assert.AreEqual(2, p2.NumOrdinates);
Assert.AreEqual(new Point(400, 100), p2 + new Point(-50, -20));
Assert.AreEqual(new Point(500, 100), p2 - new Point(-50, 20));
Assert.AreEqual(new Point(900, 240), p2*2);
Assert.AreEqual(0, p2.Dimension);
Assert.AreEqual(450, p2[0]);
Assert.AreEqual(120, p2[1]);
Assert.IsNull(p2.Boundary());
Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.IsEmpty().GetHashCode(), p2.GetHashCode());
Assert.Greater(p2.CompareTo(p1), 0);
Assert.Less(p1.CompareTo(p2), 0);
Assert.AreEqual(p2.CompareTo(new Point(450, 120)), 0);
}
示例2: GMareCollision
/// <summary>
/// Constructs a new shape object.
/// </summary>
/// <param name="shapeMode">The desired shape.</param>
public GMareCollision(Point[] points)
{
// Set nodes.
_points = (Point[])points.Clone();
// Set node rectangles.
SetNodes();
}
示例3: DoIt
public void DoIt()
{
var point = new Point();
point.Desc.Name = "point one";
point.Desc.UId = "1-2-3";
point.X = 10;
point.Y = 20;
var point2 = (Point)point.Clone();
point2.Desc.Name = "point two";
point2.X = 200;
Console.Out.WriteLine(point);
Console.Out.WriteLine(point2);
}
示例4: APuck
public APuck(Point pos, Point speed, Point goalie)
: base(pos, speed, 0)
{
if (goalie != null)
Goalie = goalie.Clone();
}
示例5: EnumeratePointsBetween
public static bool EnumeratePointsBetween(Point from, Point to, double maxDelta, PointDelegate callback)
{
if (from.Equals(to))
return callback(from.Clone());
var c = (int)(from.GetDistanceTo(to) / maxDelta + 2);
maxDelta = from.GetDistanceTo(to) / c;
var dir = (to - from).Normalized();
for (var i = 0; i <= c; i++)
{
// from + dir * (maxDelta * i)
if (!callback(new Point(from.X + dir.X * maxDelta * i, from.Y + dir.Y * maxDelta * i)))
return false;
}
return true;
}
示例6: GetArea
public static Area GetArea(int rotation, Point lineEnd)
{
Point topLeft = lineEnd.Clone();
Point bottomRight = lineEnd.Clone();
if (rotation == (int) ArrowDirection.Up)
{
topLeft.Offset(-(ArrowHeight / 2), -ArrowWidth);
bottomRight.Offset(ArrowHeight / 2, 0);
} else if (rotation == (int) ArrowDirection.Down)
{
topLeft.Offset(-(ArrowHeight / 2), 0);
bottomRight.Offset(ArrowHeight / 2, ArrowWidth);
} else if (rotation == (int) ArrowDirection.Right)
{
topLeft.Offset(0, -(ArrowHeight / 2));
bottomRight.Offset(ArrowWidth, ArrowHeight / 2);
} else if (rotation == (int) ArrowDirection.Left)
{
topLeft.Offset(-(ArrowWidth), -(ArrowHeight / 2));
bottomRight.Offset(0, ArrowHeight / 2);
}
return new Area(topLeft, bottomRight);
}
示例7: DrawNavSymbol
public void DrawNavSymbol(Graphics g, SolidBrush sb, int x, int y, Point[] symbol, Orientation or, bool SkyDir, bool shrink)
{
Point[] pa = (Point[])symbol.Clone();
int len = pa.Length;
for (int i = 0; i < len; i++)
{
switch (or)
{
case Orientation.mirrorX:
pa[i].X = NavSymbol_size - pa[i].X;
break;
case Orientation.mirrorY:
pa[i].Y = NavSymbol_size - pa[i].Y;
break;
case Orientation.right:
pa[i].Y = symbol[i].X;
pa[i].X = NavSymbol_size - symbol[i].Y;
break;
case Orientation.left:
pa[i].Y = NavSymbol_size - symbol[i].X;
pa[i].X = symbol[i].Y;
break;
}
if (SkyDir)
if (or == Orientation.right || or == Orientation.left)
pa[i].Y -= NavSymbol_size / 5;
else
pa[i].X -= NavSymbol_size / 5;
if (shrink)
{
pa[i].X /= 2;
pa[i].Y /= 2;
}
pa[i].X += x;
pa[i].Y += y;
}
Pen pen = new Pen(Color.Black, NavSymbol_size / (shrink ? 24 : 12));
g.DrawPolygon(pen, pa);
g.FillPolygon(sb, pa);
if (symbol == arrow_to)
{
DrawNavSymbol(g, sb, x, y, line_to, or, false, shrink); //draw other parts of symbol
if (SkyDir)
{
string s;
int dx, dy;
float fontsize;
int quot;
switch (or)
{
case Orientation.normal: s = "N"; dx = 60; dy = 50; break;
case Orientation.left: s = "W"; dx = 50; dy = 50; break;
case Orientation.right: s = "E"; dx = 0; dy = 40; break;
case Orientation.mirrorY: s = "S"; dx = 60; dy = -10; break;
default: s = ""; dx = x; dy = y; break;
}
if (shrink)
{ fontsize = 8; quot = 200; }
else
{ fontsize = 20; quot = 100; }
Font font = new Font("Arial", fontsize * parent.df, FontStyle.Bold);
dx = dx * NavSymbol_size / quot + x;
dy = dy * NavSymbol_size / quot + y;
g.DrawString(s, font, sb, dx, dy);
}
}
}
示例8: RecalibratePolygon
public Point[] RecalibratePolygon(Point[] akershusPoly)
{
Point[] tempList = (Point[])akershusPoly.Clone();
//for (int i = 0; i < tempList.Length; i++)
//{
// tempList[i].X = tempList[i].X + m_game.MapProvider.Map.Rectangle.X;
// tempList[i].Y = tempList[i].Y + m_game.MapProvider.Map.Rectangle.Y;
//}
for (int i = 0; i < tempList.Length; i++)
{
tempList[i] = RecalibratePoint( tempList[i] );
}
return tempList;
}
示例9: refine_center
private Point[] refine_center(Point[] last_center, Image<Gray, Byte> img)
{
Point[] center = last_center.Clone() as Point[];
for (int iter = 0; iter < 3; iter++)
{
for (int i = 0; i < 2; i++)
{
Rectangle ROI = new Rectangle(Math.Max(center[i].X - 50,0),Math.Max( center[i].Y - 50,0),Math.Min(center[i].X+50,img.Width),Math.Min(center[i].Y+50,img.Height));
ROI.Width -= ROI.X;
ROI.Height -= ROI.Y;
try
{
Emgu.CV.CvInvoke.cvSetImageROI(img, ROI);
if (img.GetMoments(false).GravityCenter.x > 0)
{
center[i].X = ROI.X + (int)img.GetMoments(false).GravityCenter.x;
center[i].Y = ROI.Y + (int)img.GetMoments(false).GravityCenter.y;
}
}
catch { }
Emgu.CV.CvInvoke.cvResetImageROI(img);
}
}
return center;
}
示例10: PolygonRegularizer
private PolygonRegularizer(Point[] vertices)
{
this.vertices = (Point[])vertices.Clone();
}
示例11: Main
public static void Main()
{
Point p1 = new Point(50, 50);
Point p2 = p1;
p2.X = 0;
Console.WriteLine(p1);
Console.WriteLine(p2);
Point p3 = new Point(100, 100);
Point p4 = (Point) p3.Clone();
p4.Y = 0;
Console.WriteLine(p3);
Console.WriteLine(p4);
Point2 p5 = new Point2(100, 100, "Jane");
Point2 p6 = (Point2) p5.Clone();
Console.WriteLine(p5);
Console.WriteLine(p6);
p6.desc.PetName = "My new Point2";
p6.X = 9;
Console.WriteLine(p5);
Console.WriteLine(p6);
}
示例12: Area
public Area(Point topLeft, Point bottomRight)
{
TopLeft = topLeft.Clone();
BottomRight = bottomRight.Clone();
}