本文整理汇总了C#中Rectangle.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Scale方法的具体用法?C# Rectangle.Scale怎么用?C# Rectangle.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override int Draw(IDrawContext drawContext, Transform transform)
{
this.SetSampler(drawContext);
this.drawnElementsLastFrame = 0;
for (var i = 0; i < this.MapSize.Width; i++)
for (var j = 0; j < this.MapSize.Height; j++)
{
if (this.map[i, j].ShouldDraw)
{
var hexDistance = this.HexSize.Width - (this.HexSize.Width - this.TopEdgeLength) / 2;
var halfHeight = this.HexSize.Height / 2;
var rectangle = new Rectangle(
this.Offset.X + i * hexDistance,
this.Offset.Y + j * this.HexSize.Height + (i % 2 == 1 ? halfHeight : 0),
this.HexSize.Width, this.HexSize.Height);
var destination = rectangle
.Scale(drawContext.Camera.ZoomFactor)
.Translate(drawContext.Camera.GetSceneTranslationVector(this.ParallaxScrollingVector));
if (drawContext.Camera.Viewport.IsVisible(destination))
{
this.map[i, j].Draw(drawContext, destination);
this.drawnElementsLastFrame++;
}
}
}
return this.drawnElementsLastFrame;
}
示例2: Draw
public override int Draw(IDrawContext drawContext, Transform transform)
{
this.SetSampler(drawContext);
this.drawnElementsLastFrame = 0;
for (var i = 0; i < this.MapSize.Width; i++)
for (var j = 0; j < this.MapSize.Height; j++)
{
if (this.map[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 (this.CameraMode == CameraMode.Follow)
{
destination = destination
.Scale(drawContext.Camera.ZoomFactor)
.Translate(drawContext.Camera.GetSceneTranslationVector(this.ParallaxScrollingVector));
}
if (drawContext.Camera.Viewport.IsVisible(destination))
{
this.map[i, j].Draw(drawContext, destination);
this.drawnElementsLastFrame++;
}
}
}
return this.drawnElementsLastFrame;
}