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


C# DrawContext.Set方法代码示例

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


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

示例1: Draw

        public override void Draw(DrawContext context, PxRect pxrect, PxRect? pxsampleRect = null, DrawColor? color = null)
        {
            context.Set();
            Rectangle rect = pxrect.Rectangle();
            Rectangle sampleRect;
            if (pxsampleRect == null) sampleRect = texture.Bounds;
            else sampleRect = pxsampleRect.Value.Rectangle();

            // top left
            DrawBatch.Draw(texture, rect.MarginTop(fh).MarginLeft(fw).PxRect(), sampleRect.MarginTop(fh).MarginLeft(fw).PxRect(), color);
            // top
            DrawBatch.Draw(texture, rect.MarginTop(fh).Inflated(-fw, 0).PxRect(), sampleRect.MarginTop(fh).Inflated(-fw, 0).PxRect(), color);
            // top right
            DrawBatch.Draw(texture, rect.MarginTop(fh).MarginRight(fw).PxRect(), sampleRect.MarginTop(fh).MarginRight(fw).PxRect(), color);
            // left
            DrawBatch.Draw(texture, rect.Inflated(0, -fh).MarginLeft(fw).PxRect(), sampleRect.Inflated(0, -fh).MarginLeft(fw).PxRect(), color);
            // center
            DrawBatch.Draw(texture, rect.Inflated(-fw, -fh).PxRect(), sampleRect.Inflated(-fw, -fh).PxRect(), color);
            // right
            DrawBatch.Draw(texture, rect.Inflated(0, -fh).MarginRight(fw).PxRect(), sampleRect.Inflated(0, -fh).MarginRight(fw).PxRect(), color);
            // bottom left
            DrawBatch.Draw(texture, rect.MarginBottom(fh).MarginLeft(fw).PxRect(), sampleRect.MarginBottom(fh).MarginLeft(fw).PxRect(), color);
            // bottom
            DrawBatch.Draw(texture, rect.MarginBottom(fh).Inflated(-fw, 0).PxRect(), sampleRect.MarginBottom(fh).Inflated(-fw, 0).PxRect(), color);
            // bottom right
            DrawBatch.Draw(texture, rect.MarginBottom(fh).MarginRight(fw).PxRect(), sampleRect.MarginBottom(fh).MarginRight(fw).PxRect(), color);
        }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:27,代码来源:Drawable9Patch.cs

示例2: Draw

        public override void Draw(DrawContext context, PxRect rect, PxRect? sampleRect = null, DrawColor? color = null)
        {
            if (dirty) { BuildTexture(); dirty = false; }
            context.Set();

            int hoff = 0;
            int voff = (rect.H / 2) - (texture.Bounds.Height / 2);
            if (align == TextAlign.Right) hoff = rect.W - texture.Bounds.Width;
            else if (align == TextAlign.Center) hoff = (rect.W / 2) - (texture.Bounds.Width / 2);

            DrawBatch.Draw(texture, new PxRect(rect.Position + new PxVector(hoff, voff), texture.Bounds.Size.PxVector()), sampleRect, color);
            //DrawBatch.Draw(texture, rect, sampleRect, color);
        }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:13,代码来源:TextDrawableFreetype.cs

示例3: Draw

 public override void Draw(DrawContext context, FxVector position, FxVector? align = null, PxRect? sampleRect = null, DrawColor? color = null, float rotation = 0, FxVector? scale = null)
 {
     context.Set();
     DrawBatch.Draw(texture, position, align, sampleRect, color, rotation, scale);
 }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:5,代码来源:DrawableTexture.cs


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