本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.ToPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.ToPolygon方法的具体用法?C# Rectangle.ToPolygon怎么用?C# Rectangle.ToPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.ToPolygon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhichEdge
public static EdgePosition WhichEdge( Rectangle rect, float angleInRadians, Vector2 point, int edgeWidth )
{
var topGrap = new Rectangle( rect.X, rect.Y, rect.Width, edgeWidth ) ;
var bottomGrab = new Rectangle( rect.X, rect.Bottom - edgeWidth, rect.Width, edgeWidth ) ;
var leftGrab = new Rectangle( rect.X, rect.Y, edgeWidth, rect.Height ) ;
var rightGrab = new Rectangle( rect.X + rect.Width - edgeWidth, rect.Y, edgeWidth, rect.Height ) ;
var center = rect.Center ;
Vector2 pivot = center.ToVector2( ) ;
if( topGrap.ToPolygon( ).RotateAroundPoint( pivot, angleInRadians ).ContainsPoint(point ) )
{
return EdgePosition.Top ;
}
if( bottomGrab.ToPolygon( ).RotateAroundPoint( pivot, angleInRadians ).ContainsPoint(point ) )
{
return EdgePosition.Bottom ;
}
if( leftGrab.ToPolygon( ).RotateAroundPoint( pivot, angleInRadians ).ContainsPoint(point ) )
{
return EdgePosition.Left ;
}
if( rightGrab.ToPolygon( ).RotateAroundPoint( pivot, angleInRadians ).ContainsPoint(point ) )
{
return EdgePosition.Right ;
}
return EdgePosition.None ;
}
示例2: rotateRectangleAroundCenter
static Vector2[] rotateRectangleAroundCenter( Rectangle rectangle, float angleInRadians )
{
Vector2[ ] points = rectangle.ToPolygon( ) ;
Vector2 center = rectangle.Center.ToVector2( ) ;
for( int i = 0; i < points.Length; i++ )
{
points[ i ] = points[ i ].RotateAroundPoint(center, angleInRadians ) ;
}
return points ;
}