当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Translate方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:plaurin,项目名称:MonoGameEngine2D,代码行数:32,代码来源:ScalableTileLayer.cs

示例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);
                }
            }
        }
开发者ID:fealty,项目名称:Frost,代码行数:37,代码来源:Painter.cs

示例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);
            }
        }
开发者ID:fealty,项目名称:Frost,代码行数:19,代码来源:Painter.cs


注:本文中的Rectangle.Translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。