views:

51

answers:

2

I trying to port System.Drawing: public LinearGradientBrush( Rectangle rect, Color color1, Color color2, float angle ) to System.Windows.Media . I can get the angle to be correct but I can't get the start and end to be at the corners. I have tried scaling the brush's transform but that ends up messing the angle.

alt text

System.Drawing.Drawing2D.LinearGradientBrush: http://msdn.microsoft.com/en-us/library/ms142563.aspx

System.Windows.Media.LinearGradientBrush: http://msdn.microsoft.com/en-us/library/ms602517.aspx

+1  A: 

The corners are good, the gamma correction looks different. The WPF LinearGradientBrush indeed has a GammaCorrection property. Play with it.

Hans Passant
A: 

I am calculating my start and end points using the intersection of the gradient axis (red line) and the line (blue) perpendicular to the gradient axis that also intersects a corner of the rectangle.

alt text

phi
Is this an answer or more details? If it is more details, you could edit your post to add the extra details there and then delete this answer.
Otaku