I have a rectangle and an angle. I need to provide the start and end points of a LinearGrad开发者_运维知识库ientBrush
in C# so that the gradient always fits perfectly within this rectangle and never under or over-extends the rectangle.
Could some of you mathletes out there help me out? I'm sure there's a really simple solution to this.
Would the following work (I am unable to test it):
var myBrush = new LinearGradientBrush(Color.Red, Color.Black, myAngle);
myBrush.StartPoint = new Point(myRectangle.X, myRectangle.Y);
myBrush.EndPoint = new Point(myRectangle.X+myRectangle.Width, myRectangle.Y+myRectangle.height);
精彩评论