2

It seems to me that all the effects available in Win2D are for drawing image.

What about CanvasGeometry? How do I draw a CanvasGeometry using, say glowing effect ?

Thanks.

Muzib
  • 2,412
  • 3
  • 21
  • 32

1 Answers1

1

Geometry objects provide a means of drawing and manipulating geometric shapes. It has CreatePolygon,CreatePathmethod could be used to create geometric shapes.

For glowing effect, you could refer this 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);
     }
}
Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • Thanks a lot. So, `CanvasCommandList` did the trick. I was looking for something like it. – Muzib Sep 03 '18 at 07:17