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


C# RectangleF.Offset方法代码示例

本文整理汇总了C#中RectangleF.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.Offset方法的具体用法?C# RectangleF.Offset怎么用?C# RectangleF.Offset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RectangleF的用法示例。


在下文中一共展示了RectangleF.Offset方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestOffset

    public void TestOffset() {
      RectangleF testRectangle = new RectangleF(1.2f, 3.4f, 5.6f, 7.8f);

      testRectangle.Offset(new Vector2(100.0f, 100.0f));

      Assert.AreEqual(101.2f, testRectangle.X);
      Assert.AreEqual(103.4f, testRectangle.Y);
      Assert.AreEqual(5.6f, testRectangle.Width);
      Assert.AreEqual(7.8f, testRectangle.Height);
    }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:10,代码来源:RectangleF.Test.cs

示例2: Draw

        public override void Draw(TimeSpan gameTime)
        {
            if (this.Rectangles != null)
            {
                var entityOffset = new Vector2(this.transform2D.Rectangle.Width, this.transform2D.Rectangle.Height) * this.transform2D.Origin;

                foreach (var spriteRectangle in this.Rectangles)
                {
                    var rectangle = new RectangleF(
                                (spriteRectangle.X - entityOffset.X) * this.transform2D.XScale,
                                (spriteRectangle.Y - entityOffset.Y) * this.transform2D.YScale,
                                spriteRectangle.Width * this.transform2D.XScale,
                                spriteRectangle.Height * this.transform2D.YScale);

                    rectangle.Offset(this.transform2D.X, this.transform2D.Y);

                    this.RenderManager.LineBatch2D.DrawRectangle(rectangle, Color.White);
                }
            }
        }
开发者ID:joeromero,项目名称:WaveAssetsViewer,代码行数:20,代码来源:SpritesheetRectanglesRenderer.cs

示例3: OffsetTest

        public void OffsetTest(float x, float y, float width, float height)
        {
            RectangleF r1 = new RectangleF(x, y, width, height);
            RectangleF expectedRect = new RectangleF(x + width, y + height, width, height);
            PointF p = new PointF(width, height);

            r1.Offset(p);
            Assert.Equal(expectedRect, r1);

            expectedRect.Offset(p);
            r1.Offset(width, height);
            Assert.Equal(expectedRect, r1);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:13,代码来源:RectangleFTests.cs

示例4: OffsetTest1

        public void OffsetTest1()
        {
            RectangleF target = new RectangleF(0f, 0f, 100f, 100f);

            target.Offset(new Vector2(10f, 10f));

            Assert.AreEqual(10f, target.X);
            Assert.AreEqual(10f, target.Y);
            Assert.AreEqual(110f, target.Right);
            Assert.AreEqual(110f, target.Bottom);
        }
开发者ID:shadercoder,项目名称:Icicle-Framework,代码行数:11,代码来源:RectangleFTest.cs

示例5: GenerateVertices

        private void GenerateVertices()
        {
            var texture = (this.ninePatch.Material as StandardMaterial).Diffuse;

            this.lastTexturePath = this.ninePatch.TexturePath;

            if (this.transform2D.Rectangle.IsEmpty)
            {
                var rectangle = this.transform2D.Rectangle;
                rectangle.Width = texture.Width;
                rectangle.Height = texture.Height;
                this.transform2D.Rectangle = rectangle;
            }

            this.lastTransformRectangleCenter = this.transform2D.Rectangle.Center;

            Vector2 origin = this.transform2D.Origin;
            float halfWidth = this.transform2D.Rectangle.Width;
            float halfHeight = this.transform2D.Rectangle.Height;
            float originCorrectionWidth = origin.X * halfWidth;
            float originCorrectionHeight = origin.Y * halfHeight;

            Color color = this.ninePatch.TintColor * this.lastTransformOpacity;

            var outputRectangle = new RectangleF(
                    0,
                    0,
                    halfWidth,
                    halfHeight);
            var outputRectangleCoords = new RectangleF(0, 0, 1, 1);

            var stretchableRectangleCoords = this.ninePatch.StretchableRectangleCoords;
            var stretchableRectangle = this.ninePatch.StretchableRectangle;

            // Ajust stretchable rectangle to rectangle size
            stretchableRectangle.Width = outputRectangle.Width - (texture.Width - stretchableRectangle.Width);
            stretchableRectangle.Height = outputRectangle.Height - (texture.Height - stretchableRectangle.Height);

            // Origin Offset
            outputRectangle.Offset(-originCorrectionWidth, -originCorrectionHeight);
            stretchableRectangle.Offset(-originCorrectionWidth, -originCorrectionHeight);

            this.vertices = new VertexPositionColorTexture[16];

            // Top-Left Vertices
            vertices[0].Position = new Vector3(outputRectangle.Left, outputRectangle.Top, 0);
            vertices[0].Color = color;
            vertices[0].TexCoord = new Vector2(outputRectangleCoords.Left, outputRectangleCoords.Top);

            vertices[1].Position = new Vector3(stretchableRectangle.Left, outputRectangle.Top, 0);
            vertices[1].Color = color;
            vertices[1].TexCoord = new Vector2(stretchableRectangleCoords.Left, outputRectangleCoords.Top);

            vertices[2].Position = new Vector3(stretchableRectangle.Left, stretchableRectangle.Top, 0);
            vertices[2].Color = color;
            vertices[2].TexCoord = new Vector2(stretchableRectangleCoords.Left, stretchableRectangleCoords.Top);

            vertices[3].Position = new Vector3(outputRectangle.Left, stretchableRectangle.Top, 0);
            vertices[3].Color = color;
            vertices[3].TexCoord = new Vector2(outputRectangleCoords.Left, stretchableRectangleCoords.Top);

            // Top-Right Vertices
            vertices[4].Position = new Vector3(stretchableRectangle.Right, outputRectangle.Top, 0);
            vertices[4].Color = color;
            vertices[4].TexCoord = new Vector2(stretchableRectangleCoords.Right, outputRectangleCoords.Top);

            vertices[5].Position = new Vector3(outputRectangle.Right, outputRectangle.Top, 0);
            vertices[5].Color = color;
            vertices[5].TexCoord = new Vector2(outputRectangleCoords.Right, outputRectangleCoords.Top);

            vertices[6].Position = new Vector3(outputRectangle.Right, stretchableRectangle.Top, 0);
            vertices[6].Color = color;
            vertices[6].TexCoord = new Vector2(outputRectangleCoords.Right, stretchableRectangleCoords.Top);

            vertices[7].Position = new Vector3(stretchableRectangle.Right, stretchableRectangle.Top, 0);
            vertices[7].Color = color;
            vertices[7].TexCoord = new Vector2(stretchableRectangleCoords.Right, stretchableRectangleCoords.Top);

            // Bottom-Left Vertices
            vertices[8].Position = new Vector3(outputRectangle.Left, stretchableRectangle.Bottom, 0);
            vertices[8].Color = color;
            vertices[8].TexCoord = new Vector2(outputRectangleCoords.Left, stretchableRectangleCoords.Bottom);

            vertices[9].Position = new Vector3(stretchableRectangle.Left, stretchableRectangle.Bottom, 0);
            vertices[9].Color = color;
            vertices[9].TexCoord = new Vector2(stretchableRectangleCoords.Left, stretchableRectangleCoords.Bottom);

            vertices[10].Position = new Vector3(stretchableRectangle.Left, outputRectangle.Bottom, 0);
            vertices[10].Color = color;
            vertices[10].TexCoord = new Vector2(stretchableRectangleCoords.Left, outputRectangleCoords.Bottom);

            vertices[11].Position = new Vector3(outputRectangle.Left, outputRectangle.Bottom, 0);
            vertices[11].Color = color;
            vertices[11].TexCoord = new Vector2(outputRectangleCoords.Left, outputRectangleCoords.Bottom);

            // Bottom-Right Vertices
            vertices[12].Position = new Vector3(stretchableRectangle.Right, stretchableRectangle.Bottom, 0);
            vertices[12].Color = color;
            vertices[12].TexCoord = new Vector2(stretchableRectangleCoords.Right, stretchableRectangleCoords.Bottom);

//.........这里部分代码省略.........
开发者ID:WaveEngine,项目名称:Samples,代码行数:101,代码来源:NinePatchRenderer.cs

示例6: DrawOutlinedText

 private static void DrawOutlinedText (Graphics graphic, StringFormat strFormatter, string text, Font font, SizeF measure, float hPos)
 {
     RectangleF rect = new RectangleF(new PointF(10f, hPos), measure);
     SolidBrush whiteBrush = new SolidBrush(Color.White);
     SolidBrush blackBrush = new SolidBrush(Color.Black);
     rect.Offset(-2, 0);
     graphic.DrawString(text, font, blackBrush, rect, strFormatter);
     rect.Offset(0, -2);
     graphic.DrawString(text, font, blackBrush, rect, strFormatter);
     rect.Offset(2, 0);
     graphic.DrawString(text, font, blackBrush, rect, strFormatter);
     rect.Offset(1, 0);
     graphic.DrawString(text, font, blackBrush, rect, strFormatter);
     rect.Offset(0, 2);
     graphic.DrawString(text, font, blackBrush, rect, strFormatter);
     rect.Offset(0, 1);
     graphic.DrawString(text, font, blackBrush, rect, strFormatter);
     rect.Offset(-2, -2);
     graphic.DrawString(text, font, whiteBrush, rect, strFormatter);
 }
开发者ID:SwarmCorp,项目名称:Swarmops,代码行数:20,代码来源:DisplayActivism.aspx.cs

示例7: Painter

    private void Painter(object sender, PaintEventArgs args)
    {
        // текущее положение струга {м}
        double tpslt = (double)this.InputParameters["tpslt"].Value;
        // длина струга {м}
        double dslc = (double)this.InputParameters["dslc"].Value;
        // высота струга {м}
        double vshc = (double)this.InputParameters["vshc"].Value;
        // длина СУ {м}
        double lysu = (double)this.InputParameters["lysu"].Value;
        // высота плиты {м}
        double hysu = (double)this.InputParameters["hysu"].Value;
        // длина резца {м}
        double drlp = (double)this.InputParameters["drlp"].Value;
        // сторона резца {м}
        double srsp = (double)this.InputParameters["srsp"].Value;

        Form frm = (Form)sender;
        SizeF formsize = frm.ClientSize;
        Pen pn = new Pen(Color.Black, 0);

        // Считаем коэффициент
        float tempX = (formsize.Width - 100f) / ((float)lysu - (float)tpslt + (float)drlp);
        float tempY = (formsize.Height - 100f) / ((float)hysu + (float)vshc);

        float multiplier;
        if (tempX < tempY)
            multiplier = tempX;
        else
            multiplier = tempY;

        PointF LeftTopPoint = new PointF();

        LeftTopPoint.X = formsize.Width / 2f - ((float)lysu - (float)tpslt + (float)drlp) / 2f * multiplier;
        LeftTopPoint.Y = formsize.Height / 2f + ((float)hysu + (float)vshc) / 2f * multiplier;
        LeftTopPoint.Y -= (float)hysu * multiplier;

        SizeF Dimensions = new SizeF((float)lysu * multiplier, (float)hysu * multiplier);
        RectangleF Foundation = new RectangleF(LeftTopPoint, Dimensions);
        args.Graphics.DrawRectangle(pn, Rectangle.Round(Foundation));

        string str = lysu.ToString() + " м";
        LeftTopPoint.X = Foundation.X + Foundation.Width / 2f;
        LeftTopPoint.Y = Foundation.Bottom;
        args.Graphics.DrawString(str, SystemFonts.DefaultFont, SystemBrushes.WindowText, LeftTopPoint);
        str = hysu.ToString() + " м";
        LeftTopPoint.X = Foundation.X;
        LeftTopPoint.Y = Foundation.Bottom - Foundation.Height / 2f - SystemFonts.DefaultFont.GetHeight(args.Graphics) / 2f;
        args.Graphics.DrawString(str, SystemFonts.DefaultFont, SystemBrushes.WindowText, LeftTopPoint);

        LeftTopPoint.X = Foundation.Right - ((float)tpslt + (float)dslc) * multiplier;
        LeftTopPoint.Y = Foundation.Top - (float)vshc * multiplier;

        Dimensions = new SizeF((float)dslc * multiplier, (float)vshc * multiplier);
        RectangleF Plow = new RectangleF(LeftTopPoint, Dimensions);

        args.Graphics.DrawRectangle(pn, Rectangle.Round(Plow));

        str = dslc.ToString() + " м";
        LeftTopPoint.X = Plow.X + Plow.Width / 2f;
        LeftTopPoint.Y = Plow.Top - SystemFonts.DefaultFont.GetHeight(args.Graphics);
        args.Graphics.DrawString(str, SystemFonts.DefaultFont, SystemBrushes.WindowText, LeftTopPoint);
        str = vshc.ToString() + " м";
        LeftTopPoint.X = Plow.X;
        LeftTopPoint.Y = Plow.Bottom - Plow.Height / 2f - SystemFonts.DefaultFont.GetHeight(args.Graphics) / 2f;
        args.Graphics.DrawString(str, SystemFonts.DefaultFont, SystemBrushes.WindowText, LeftTopPoint);

        LeftTopPoint.X = Plow.Right;
        LeftTopPoint.Y = Plow.Y + (Plow.Height / 2f - (float)srsp / 2f * multiplier) - Plow.Height / 4f;

        Dimensions = new SizeF((float)drlp * multiplier, (float)srsp * multiplier);
        RectangleF CuttingTool_1 = new RectangleF(LeftTopPoint, Dimensions);
        RectangleF CuttingTool_2 = new RectangleF(CuttingTool_1.Location, CuttingTool_1.Size);
        CuttingTool_2.Offset(0f, Plow.Height / 2f);

        args.Graphics.DrawRectangle(pn, Rectangle.Round(CuttingTool_1));
        args.Graphics.DrawRectangle(pn, Rectangle.Round(CuttingTool_2));

        str = drlp.ToString() + " м";
        LeftTopPoint.X = CuttingTool_1.X;
        LeftTopPoint.Y = CuttingTool_1.Bottom;
        args.Graphics.DrawString(str, SystemFonts.DefaultFont, SystemBrushes.WindowText, LeftTopPoint);
        str = srsp.ToString() + " м";
        LeftTopPoint.X = CuttingTool_1.Right;
        LeftTopPoint.Y = CuttingTool_1.Bottom - CuttingTool_1.Height / 2f - SystemFonts.DefaultFont.GetHeight(args.Graphics) / 2f;
        args.Graphics.DrawString(str, SystemFonts.DefaultFont, SystemBrushes.WindowText, LeftTopPoint);
    }
开发者ID:SaprSu,项目名称:SaprSu,代码行数:87,代码来源:graphic_expression.cs


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