如何在CanvasGeometry上添加效果

问题描述 投票:2回答:1

在我看来,Win2D中可用的所有效果都是用于绘制图像。

怎么样CanvasGeometry?如何使用发光效果绘制CanvasGeometry

谢谢。

uwp graphics2d win2d windows-composition-api
1个回答
1
投票

Geometry对象提供了绘制和操纵几何形状的方法。它有CreatePolygonCreatePathmethod可用于创建几何形状。

对于发光效果,你可以参考这个code sample

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);
     }
}
© www.soinside.com 2019 - 2024. All rights reserved.