本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.PxRect方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.PxRect方法的具体用法?C# Rectangle.PxRect怎么用?C# Rectangle.PxRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.PxRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddGlyph
void AddGlyph(char c)
{
const int buffer = 2;
fontFace.LoadGlyph(fontFace.GetCharIndex(c), loadFlags, loadTarget);
fontFace.Glyph.RenderGlyph(renderMode);
int w = (int)Math.Ceiling((float)fontFace.Glyph.Metrics.HorizontalAdvance);
int h = (int)Math.Ceiling((float)fontFace.Glyph.Metrics.Height);
if (lineOffset + w + buffer > atlas.Width) {
lineOffset = 0;
lineNum++;
}
if ((lineNum + 1) * lineSize > atlas.Height) throw new Exception("Font atlas overflow");
Rectangle rect = new Rectangle(lineOffset, lineNum * lineSize, w, lineSize);
charRects.Add(c, rect);
lineOffset += w + buffer;
if (w <= 0 || h <= 0) return;
// and draw
Bitmap bmp = new Bitmap(w, lineSize);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);
g.Clear(System.Drawing.Color.Transparent);
FTBitmap ftb = fontFace.Glyph.Bitmap; // lol ftb
Bitmap cb = ftb.ToGdipBitmap(System.Drawing.Color.White);
g.DrawImageUnscaled(cb, (int)Math.Round((float)fontFace.Glyph.BitmapLeft), (int)Math.Round(lineSize * 0.75 - (float)fontFace.Glyph.BitmapTop));
g.Dispose();
Texture2D ch = GetTexture(GraphicsManager.device, bmp);
bmp.Dispose();
RenderTarget2D pop = DrawBatch.Target;
PxVector popOff = DrawBatch.drawOffset;
DrawBatch.Target = atlas;
DrawBatch.Draw(ch, rect.PxRect(), null, null);
DrawBatch.Target = null;
DrawBatch.Target = pop;
DrawBatch.drawOffset = popOff;
ch.Dispose();
}