本文整理汇总了C#中Rectangle.Translate方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Translate方法的具体用法?C# Rectangle.Translate怎么用?C# Rectangle.Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreDraw
public void PreDraw(IDrawContext drawContext)
{
if (this.CameraMode == GameFramework.Cameras.CameraMode.Follow
&& drawContext.Camera.ZoomFactor > 1)
{
drawContext.SetRenderTarget(this, drawContext.Camera.SceneViewport.Size);
var cameraTranslation = drawContext.Camera.SceneViewport.Positon.RoundTo(0);
for (var i = 0; i < this.MapSize.Width; i++)
for (var j = 0; j < this.MapSize.Height; j++)
{
if (this[i, j].ShouldDraw)
{
var destination = new Rectangle(
this.Offset.X + i * this.TileSize.Width,
this.Offset.Y + j * this.TileSize.Height,
this.TileSize.Width,
this.TileSize.Height);
if (drawContext.Camera.SceneViewport.IsVisible(destination))
{
var adjustedDestination = destination.Translate(-cameraTranslation);
this[i, j].Draw(drawContext, adjustedDestination);
}
}
}
drawContext.FlushRenderTarget();
}
}
示例2: FillRectangle
public void FillRectangle(
float rectangleX,
float rectangleY,
float rectangleWidth,
float rectangleHeight,
float roundedRadiusWidth = 0.0f,
float roundedRadiusHeight = 0.0f)
{
Contract.Requires(Thread.CurrentThread == BoundThread);
Contract.Requires(ActiveTarget != null);
Contract.Requires(Check.IsFinite(rectangleX));
Contract.Requires(Check.IsFinite(rectangleY));
Contract.Requires(Check.IsPositive(rectangleWidth));
Contract.Requires(Check.IsPositive(rectangleHeight));
Contract.Requires(Check.IsPositive(roundedRadiusWidth));
Contract.Requires(Check.IsPositive(roundedRadiusHeight));
if(!_IsTargetEmpty)
{
Rectangle region = new Rectangle(
rectangleX, rectangleY, rectangleWidth, rectangleHeight);
// translate to 2D surface coordinate space
region = region.Translate(_TargetDelta);
Size radius = new Size(roundedRadiusWidth, roundedRadiusHeight);
if(radius == Size.Empty)
{
OnFillRectangle(ref region);
}
else
{
OnFillRectangle(ref region, ref radius);
}
}
}
示例3: Clear
public void Clear(float x, float y, float width, float height)
{
Contract.Requires(Thread.CurrentThread == BoundThread);
Contract.Requires(ActiveTarget != null);
Contract.Requires(Check.IsFinite(x));
Contract.Requires(Check.IsFinite(y));
Contract.Requires(Check.IsPositive(width));
Contract.Requires(Check.IsPositive(height));
if(!_IsTargetEmpty)
{
Rectangle region = new Rectangle(x, y, width, height);
// translate to 2D surface coordinate space
region = region.Translate(_TargetDelta);
OnClear(ref region);
}
}