本文整理汇总了C#中Microsoft.Graphics.Canvas.CanvasDrawingSession.CreateLayer方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasDrawingSession.CreateLayer方法的具体用法?C# CanvasDrawingSession.CreateLayer怎么用?C# CanvasDrawingSession.CreateLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Graphics.Canvas.CanvasDrawingSession
的用法示例。
在下文中一共展示了CanvasDrawingSession.CreateLayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
/// <summary>
/// Draws a raindrop on canvas at the current position.
/// </summary>
public void Draw(RainyDay rainyday, CanvasDrawingSession context)
{
float orgR = r;
r = 0.95f * r;
if (r < 3)
{
clipGeo = CanvasGeometry.CreateCircle(context, new Vector2(x, y), r);
}
else if (colliding != null || yspeed > 2)
{
if (colliding != null)
{
var collider = colliding;
r = 1.001f * (r > collider.r ? r : collider.r);
x += (collider.x - x);
colliding = null;
}
float yr = 1 + 0.1f * yspeed;
using (CanvasPathBuilder path = new CanvasPathBuilder(context))
{
path.BeginFigure(x - r / yr, y);
path.AddCubicBezier(new Vector2(x - r, y - r * 2), new Vector2(x + r, y - r * 2), new Vector2(x + r / yr, y));
path.AddCubicBezier(new Vector2(x + r, y + yr * r), new Vector2(x - r, y + yr * r), new Vector2(x - r / yr, y));
path.EndFigure(CanvasFigureLoop.Closed);
clipGeo = CanvasGeometry.CreatePath(path);
}
}
else
{
clipGeo = CanvasGeometry.CreateCircle(context, new Vector2(x, y), 0.9f * r);
}
r = orgR;
if (rainyday.Reflection != null)
{
using (context.CreateLayer(1, clipGeo))
{
rainyday.Reflection(context, this);
}
}
if (clipGeo != null)
{
clipGeo.Dispose();
}
}