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