本文整理汇总了C#中Microsoft.Graphics.Canvas.CanvasDrawingSession.DrawTextLayout方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasDrawingSession.DrawTextLayout方法的具体用法?C# CanvasDrawingSession.DrawTextLayout怎么用?C# CanvasDrawingSession.DrawTextLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Graphics.Canvas.CanvasDrawingSession
的用法示例。
在下文中一共展示了CanvasDrawingSession.DrawTextLayout方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawTextOverWhiteRectangle
private static void DrawTextOverWhiteRectangle(CanvasDrawingSession ds, Vector2 paddedTopLeft, CanvasTextLayout textLayout)
{
var bounds = textLayout.LayoutBounds;
var rect = new Rect(bounds.Left + paddedTopLeft.X, bounds.Top + paddedTopLeft.Y, bounds.Width, bounds.Height);
ds.FillRectangle(rect, Colors.White);
ds.DrawTextLayout(textLayout, paddedTopLeft, Colors.Black);
}
示例2: drawText
public void drawText(CanvasDrawingSession ds, Color color)
{
ds.DrawTextLayout(textLayout, (float)location.X, (float)location.Y, color);
}
示例3: DoEffect
private void DoEffect(CanvasDrawingSession ds, Size size, float amount)
{
size.Width = size.Width - ExpandAmount;
size.Height = size.Height - ExpandAmount;
var offset = (float)(ExpandAmount / 2);
using (var textLayout = CreateTextLayout(ds, size))
using (var textCommandList = new CanvasCommandList(ds))
{
using (var textDs = textCommandList.CreateDrawingSession())
{
textDs.DrawTextLayout(textLayout, 0, 0, GlowColor);
}
glowEffectGraph.Setup(textCommandList, amount);
ds.DrawImage(glowEffectGraph.Output, offset, offset);
ds.DrawTextLayout(textLayout, offset, offset, TextColor);
}
}
示例4: Draw
public void Draw(CanvasDrawingSession ds, int frameCounter, float width, float height)
{
++frameCounter;
float opacity = (float)(Math.Sin(frameCounter * 0.05) + 1) / 2;
DoTest(opacity, ignoreSource, premultipliedTarget[0]);
DoTest(opacity, ignoreSource, ignoreTarget[0]);
DoTest(opacity, premultipliedSource, premultipliedTarget[1]);
DoTest(opacity, premultipliedSource, ignoreTarget[1]);
float halfWidth = width / 2;
var premultipliedToIgnoreLabel = MakeLabel(ds, "Draw Premultiplied to Ignore", halfWidth);
var premultipliedToPremultipliedLabel = MakeLabel(ds, "Draw Premultiplied to Premultiplied", halfWidth);
var ignoreToIgnoreLabel = MakeLabel(ds, "Draw Ignore to Ignore", halfWidth);
var ignoreToPremultipliedLabel = MakeLabel(ds, "Draw Ignore to Premultiplied", halfWidth);
var totalHeight = 64 * 8.0f;
float middle = width / 2;
float imageX = middle + 10;
float textRight = middle - 10;
float y = (height / 2) - (totalHeight / 2);
float ydiff = 64.0f * 2.0f;
ds.DrawImage(premultipliedTarget[0], imageX, y);
ds.DrawTextLayout(premultipliedToPremultipliedLabel, 0, y, Colors.White);
y += ydiff;
ds.DrawImage(ignoreTarget[0], imageX, y);
ds.DrawTextLayout(premultipliedToIgnoreLabel, 0, y, Colors.White);
y += ydiff;
ds.DrawImage(premultipliedTarget[1], imageX, y);
ds.DrawTextLayout(ignoreToPremultipliedLabel, 0, y, Colors.White);
y += ydiff;
ds.DrawImage(ignoreTarget[1], imageX, y);
ds.DrawTextLayout(ignoreToIgnoreLabel, 0, y, Colors.White);
y += ydiff;
}
示例5: DrawTextWithBackground
private void DrawTextWithBackground(CanvasDrawingSession ds, CanvasTextLayout layout, double x, double y)
{
var backgroundRect = layout.LayoutBounds;
backgroundRect.X += x;
backgroundRect.Y += y;
backgroundRect.X -= 20;
backgroundRect.Y -= 20;
backgroundRect.Width += 40;
backgroundRect.Height += 40;
ds.FillRectangle(backgroundRect, Colors.White);
ds.DrawTextLayout(layout, (float)x, (float)y, Colors.Black);
}