本文整理汇总了C#中Point2类的典型用法代码示例。如果您正苦于以下问题:C# Point2类的具体用法?C# Point2怎么用?C# Point2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point2类属于命名空间,在下文中一共展示了Point2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLinePlaneIntersection
/// <summary>
/// Determines the intersection between a 2d line and a plane
/// </summary>
/// <param name="start">Line start</param>
/// <param name="end">Line end</param>
/// <param name="plane">Plane</param>
/// <returns>Returns intersection details, or null if there was no intersection.</returns>
public static Line2Intersection GetLinePlaneIntersection( Point2 start, Point2 end, Plane2 plane )
{
Vector2 vec = end - start;
float len = vec.Length;
vec /= len;
float startDot = plane.Normal.Dot( start );
float diffDot = plane.Normal.Dot( vec );
if ( !Utils.CloseToZero( diffDot ) )
{
float t = ( startDot + plane.Distance ) / -diffDot;
if ( ( t >= 0 ) && ( t <= len ) )
{
Line2Intersection result = new Line2Intersection( );
result.IntersectionPosition = start + ( vec * t );
result.IntersectionNormal = plane.Normal;
result.Distance = t;
result.StartInside = ( startDot + plane.Distance ) < 0;
return result;
}
}
return null;
}
示例2: Point2_IsConstructedProperly
public void Point2_IsConstructedProperly()
{
var result = new Point2(123, 456);
TheResultingValue(result)
.ShouldBe(123, 456);
}
示例3: OnRenderOverflowButtonBackground
protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
{
Brush triangleBrush = new SolidBrush(Color.Black);
Point2 itemCenter = new Point2(e.Item.Width / 2, e.Item.Height / 2);
int triangleSize = 2;
if (e.Item.Pressed)
{
e.Graphics.FillRectangle(
new SolidBrush(this.ColorTable.ButtonPressedHighlight),
1, 1, e.Item.Width - 2, e.Item.Height - 2);
e.Graphics.DrawRectangle(
new Pen(this.ColorTable.ButtonPressedHighlightBorder),
1, 1, e.Item.Width - 3, e.Item.Height - 3);
}
else if (e.Item.Selected)
{
e.Graphics.FillRectangle(
new SolidBrush(this.ColorTable.ButtonSelectedHighlight),
1, 1, e.Item.Width - 2, e.Item.Height - 2);
e.Graphics.DrawRectangle(
new Pen(this.ColorTable.ButtonSelectedHighlightBorder),
1, 1, e.Item.Width - 3, e.Item.Height - 3);
}
e.Graphics.FillPolygon(triangleBrush, new Point[] {
new Point(itemCenter.X - triangleSize, (e.Item.Height * 3 / 4) - triangleSize),
new Point(itemCenter.X + triangleSize + 1, (e.Item.Height * 3 / 4) - triangleSize),
new Point(itemCenter.X, (e.Item.Height * 3 / 4) + (triangleSize / 2))});
}
示例4: UpdatePreview
public override void UpdatePreview()
{
ITilemapToolEnvironment env = this.Environment;
Point2 topLeft = new Point2(
Math.Min(env.ActionBeginTile.X, env.HoveredTile.X),
Math.Min(env.ActionBeginTile.Y, env.HoveredTile.Y));
Point2 size = new Point2(
1 + Math.Abs(env.ActionBeginTile.X - env.HoveredTile.X),
1 + Math.Abs(env.ActionBeginTile.Y - env.HoveredTile.Y));
// Don't update the rect when still using the same boundary size
bool hoverInsideActiveArea = (env.ActiveOrigin == topLeft && env.ActiveArea.Width == size.X && env.ActiveArea.Height == size.Y);
if (hoverInsideActiveArea)
return;
env.ActiveOrigin = topLeft;
env.ActiveArea.ResizeClear(size.X, size.Y);
env.ActiveArea.Fill(true, 0, 0, size.X, size.Y);
// Manually define outlines in the trivial rect case
Tileset tileset = env.ActiveTilemap != null ? env.ActiveTilemap.Tileset.Res : null;
Vector2 tileSize = tileset != null ? tileset.TileSize : Tileset.DefaultTileSize;
env.ActiveAreaOutlines.Clear();
env.ActiveAreaOutlines.Add(new Vector2[]
{
new Vector2(0, 0),
new Vector2(tileSize.X * size.X, 0),
new Vector2(tileSize.X * size.X, tileSize.Y * size.Y),
new Vector2(0, tileSize.Y * size.Y),
new Vector2(0, 0) // Close the loop
});
env.SubmitActiveAreaChanges(true);
}
示例5: New
public static IViewPort New(VideoTypes videoType, IDisposableResource parent, Point2 location, Size2 size)
{
IViewPort api = null;
#if WIN32
if (videoType == VideoTypes.D3D9) api = new D3D9.ViewPort(parent, location, size);
#endif
#if WIN32 || WINRT || WP8
if (videoType == VideoTypes.D3D11) api = new D3D11.ViewPort(parent, location, size);
#endif
#if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl
if (videoType == VideoTypes.OpenGL) api = new OpenGL.ViewPort(parent, location, size);
#endif
#if XNA
if (videoType == VideoTypes.XNA) api = new XNA.ViewPort(parent, location, size);
#endif
#if VITA
if (videoType == VideoTypes.Vita) api = new Vita.ViewPort(parent, location, size);
#endif
if (api == null) Debug.ThrowError("ViewPortAPI", "Unsuported InputType: " + videoType);
return api;
}
示例6: getValidMoves
public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
{
validPoints.Clear();
Point2 checkPoint;
foreach (Point2 dir in legalMoves)
{
checkPoint = origin;
for (int i = 0; i < attackRange; i++)
{
checkPoint += dir;
if (checkPointOutOfBounds(checkPoint))
{
break;
}
print(mapProperties);
Tile tileAtPoint = mapProperties.getTile(checkPoint);
if (checkTileContainsObstacle(tileAtPoint))
{
break;
}
validPoints.Add(checkPoint);
}
}
return validPoints;
}
示例7: TilemapTileDrawSource
public TilemapTileDrawSource(Tilemap tilemap, Point2 origin, Grid<bool> area)
{
if (tilemap == null) throw new ArgumentNullException("tilemap");
this.tilemap = tilemap;
this.origin = origin;
this.area = new Grid<bool>(area);
}
示例8: getValidMoves
public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
{
validPoints.Clear();
foreach (Point2 dir in legalMoves)
{
Point2 checkPoint = origin + dir;
if (!checkPointOutOfBounds(checkPoint))
{
Tile tileAtPoint = mapProperties.getTile(checkPoint);
if (checkTileNeutral(tileAtPoint))
{
validPoints.Add(checkPoint);
}
else
{
while (checkTileOwned(tileAtPoint) && !checkTileContainsEntity(tileAtPoint))
{
validPoints.Add(checkPoint);
checkPoint += dir;
if (checkPointOutOfBounds(checkPoint))
{
break;
}
tileAtPoint = mapProperties.getTile(checkPoint);
}
}
}
}
return validPoints;
}
示例9: getAffectedTiles
public override List<Point2> getAffectedTiles(Point2 origin, Point2 affectedTile, MapProperties mapProperties)
{
List<Point2> affectedTiles = new List<Point2>();
affectedTiles.Add(origin);
affectedTiles.Add(affectedTile);
return affectedTiles;
}
示例10: epsg3140_to_wgs
public void epsg3140_to_wgs()
{
var crs = EpsgMicroDatabase.Default.GetCrs(3140);
var wgs = EpsgMicroDatabase.Default.GetCrs(4326);
// source for coordinates is http://epsg.io/3140/map
var ptWgs = new GeographicCoordinate(-17.785, 177.97);
var pt3140 = new Point2(530138.52663372, 821498.68898981); // units in links
var gen = new EpsgCrsCoordinateOperationPathGenerator();
var paths = gen.Generate(wgs, crs);
var compiler = new StaticCoordinateOperationCompiler();
var txs = paths
.Select(p => compiler.Compile(p))
.Where(p => p != null);
var forward = txs.Single();
var actualForward = (Point2)forward.TransformValue(ptWgs);
Assert.AreEqual(pt3140.X, actualForward.X, 30);
Assert.AreEqual(pt3140.Y, actualForward.Y, 30);
var reverse = forward.GetInverse();
var actualReverse = (GeographicCoordinate)reverse.TransformValue(pt3140);
Assert.AreEqual(ptWgs.Longitude, actualReverse.Longitude, 0.01);
Assert.AreEqual(ptWgs.Latitude, actualReverse.Latitude, 0.01);
}
示例11: Line2Intersection
/// <summary>
/// Setup constructor
/// </summary>
/// <param name="pos"> Ray intersection position </param>
/// <param name="normal"> Ray intersection normal </param>
/// <param name="distance"> Ray intersection distance </param>
/// <param name="obj">Intersected object</param>
public Line2Intersection( Point2 pos, Vector2 normal, float distance, object obj )
{
m_Position = pos;
m_Normal = normal;
m_Distance = distance;
m_Object = obj;
}
示例12: Main
static void Main(string[] args)
{
/********* VALUE TYPES *********/
int x = 5;
ChangeValue(x); //only set to 10 in this method, one method completes program will go back to using x value in the main arguments scope. This application will print out x being equal to 5.
Console.WriteLine("X: {0}", x);
/********* REFERENCE TYPES *********/
Point1 p1 = new Point1(); //reference types are usually classes and arrays
p1.X = 5;
p1.Y = 10;
Point1 p2 = p1;
Point1 p3 = p2;
p3.Y = 50;
Console.WriteLine(p2.Y);
Point2 p10 = new Point2();
p10.X = 10;
p10.Y = 5;
ChangePoint(p10);
Console.WriteLine("X: {0}, Y:{1}", p10.X, p10.Y);
Console.ReadLine();
}
示例13: Rectangle2
public Rectangle2(Point2 point, Size2 sizeF)
{
X = point.X;
Y = point.Y;
Width = sizeF.Width;
Height = sizeF.Height;
}
示例14: SearchNode
/// <summary>
/// Create new Search Node.
/// </summary>
/// <param name="_position">Position of the Search Node in the grid.</param>
/// <param name="_cost">Cost to move to this Node.</param>
/// <param name="_pathCost">Estimated cost of the path.</param>
/// <param name="_next">Next Search Node.</param>
public SearchNode(Point2 _position, int _cost, int _pathCost, SearchNode _next)
{
this.position = _position;
this.cost = _cost;
this.pathCost = _pathCost;
this.next = _next;
}
示例15: distanceSquaredFrom
public int distanceSquaredFrom(Point2 to)
{
int deltaX = to.X - m_position.X;
int deltaY = to.Y - m_position.Y;
return deltaX * deltaX + deltaY * deltaY;
}