如何在画布上绘制具有径向渐变的圆? [英] How to draw a circle with a radial gradient on the canvas?

查看:175
本文介绍了如何在画布上绘制具有径向渐变的圆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在自定义控件(XAML)中的画布上绘制一个带有径向渐变的圆。但是 Windows :: UI :: Xaml :: Media 仅包含 LinearGradientBrush 。我了解设计指南,但我的控件需要这样做,以便用户可以看到伽玛颜色。

在下面,我需要获取:



PS 我问至少在没有XAML的情况下如何以编程方式绘制它。

PPS 我知道我可以画一幅画在某些具有径向渐变的编辑器中,然后将其绘制在画布上,但对于自适应设计而言似乎不是一个好的解决方案。

I need to draw a circle with a radial gradient on the canvas in my custom control (XAML). But Windows::UI::Xaml::Media contains LinearGradientBrush only. I know about design guids but my control requires so feature to the user can see the color gamma.
Below that I need to get:

P.S. I ask how to draw it at least programmaticaly without XAML.
P.P.S. I know that I can draw a picture in some editor with radial gradient and after draw it on the canvas but it seems not good solution for the adaptive design.

推荐答案

您可以检查 RenderColorPickerHueRing() 方法的示例,说明如何在 WriteableBitmap 中的CPU上执行此操作。它并不是超级快(至少在C#版本中),但是至少它可以避免您将图像与应用程序打包在一起或使用DirectX,这对于正确设置和稳定它来说比较棘手。

You can check the RenderColorPickerHueRing() method for a sample of how you could do it on a CPU in a WriteableBitmap. It's not super fast (at least in the C# version), but at least it saves you from packaging another image with your app or from using DirectX, which is a bit more tricky to get set up correctly and stabilize.

这篇关于如何在画布上绘制具有径向渐变的圆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆