Creating Gradient Brush along a Circular Path

前端 未结 3 479
-上瘾入骨i
-上瘾入骨i 2020-12-05 01:15

I need to create a multi-step gradient along a circular path, as demonstrated in the following image:

\"Wheel

3条回答
  •  天涯浪人
    2020-12-05 02:13

    In GDI+/Winforms you can use the PathGradientBrush to do this:

    http://www.bobpowell.net/pgb.htm

    http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.pathgradientbrush.aspx

    Unfortunately there is no support for a PathGradientBrush in WPF but a few people have asked for it here:

    http://dotnet.uservoice.com/forums/40583-wpf-feature-suggestions/suggestions/480949-add-a-pathgradientbrush-like-in-winforms-

    (might be worth casting your vote too!)

    Because of the lack of support you cannot do it directly in XAML, you could however use GDI+ code to create an image and then use the image in your XAML. This might give you better performance than using a non-affine transformation.

提交回复
热议问题