简体   繁体   English

c#非线性渐变画笔?

[英]c# Non-Linear gradient brushes?

Is there a method I can use to generate non-linear Gradient brushes in c#? 有没有一种方法可以用来在c#中生成非线性渐变画笔?

To clarify: Im not looking for a gradient that can be applied to a non-linear path. 澄清:我不是在寻找可以应用于非线性路径的渐变。 Rather, I am looking for a gradient between 2 colours that fades between the two in a non-linear fashion ie the rate of changs is quicker at the start of the gradient and slows down as the brush nears the finishing point. 相反,我正在寻找两种颜色之间的渐变,这两种颜色之间以非线性方式逐渐消失,即在渐变开始时变化的速度更快,而在画笔接近结束点时变慢。

Is this even remotly possible in c# using gdi+? 使用gdi +在c#中是否可以实现这一点?

Yep, set the blend for the Brush. 是的,设置画笔的混合。

LinearGradientBrush blendBrush = new LinearGradientBrush(Rectangle, Color.Red, Color.White, 360f);
Blend blend = new Blend();
blend .Factors = new float[] { 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f };
blend .Positions = new float[] { 0, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f };
blendBrush.Blend = blend ;

This example will start fading out, then go back to the previous colour. 此示例将开始淡出,然后返回到上一个颜色。 So a kinda fill from centre effect. 所以从中心效果来看有点填充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM