如何制作曲线的渐变 [英] How to make the gradient of the curve

查看:171
本文介绍了如何制作曲线的渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!



如何制作曲线的渐变,例如椭圆,颜色根据某个点上的椭圆点而变化。 br />


我用来绘制DrawingContext



是否可以编写从Brush或Gradientbrush继承的画笔?

Good day!

How to make the gradient of the curve, such as an ellipse, the color changed depending point on the ellipse from a certain point.

I use to draw DrawingContext

Is it possible to write your brush inherited from Brush or Gradientbrush?

推荐答案

不,一般情况下,你将无法创建这样的画笔,画笔类只是没那么灵活。您需要计算每个像素的颜色。这是一个非常简单的事情,但它需要花费开发时间和一些处理时间。



我建议在低级像素中使用class System.Windows.Media.Imaging.WriteableBitmap

http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx [<一个href =http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspxtarget =_ blanktitle =New Window> ^ ]。



它将允许您直接使用像素数组并在计算完成后立即将其提交到位图。我担心任何其他方法都可能过于缓慢。



或者,您可以研究创建从抽象类派生的自定义画笔的可能性 System.Windows.Media.GradientBrush 或只是 System.Windows.Media.Brush

http://msdn.microsoft.com/en-us/library/system.windows.media .gradientbrush.aspx [ ^ ],

http ://msdn.microsoft.com/en-us/library/system.windows.media.brush.aspx [ ^ ]。



我不确定在您描述的情况下创建渐变画笔ed是个好主意,如果有可能的话。我对此表示怀疑。第一种方法肯定会起作用并且不会太困难。



-SA
No, in general case, you won't be able to create such a brush, brush classes are just not as much flexible. You would need to calculate colors for each individual pixel. This is a pretty simple thing, but it will take both development time, and some processing time.

I would recommend to do it in low level pixel by pixel using the class System.Windows.Media.Imaging.WriteableBitmap:
http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.writeablebitmap.aspx[^].

It will allow you working directly with an array of pixels and commit it to the bitmap at once when the calculations are done. I'm afraid any other approach could be prohibitively slow.

Alternatively, you could research the possibility of creation of a custom brush derived from the abstract class System.Windows.Media.GradientBrush or just System.Windows.Media.Brush:
http://msdn.microsoft.com/en-us/library/system.windows.media.gradientbrush.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.media.brush.aspx[^].

I'm not sure that creation of a gradient brush in the case you described is a good idea, if it is even possible. I doubt it. First approach will certainly work and won't be too difficult.

—SA


这篇关于如何制作曲线的渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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