开发者

Hard to explain, angle and rectangle involved

开发者 https://www.devze.com 2023-03-10 14:51 出处:网络
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 u

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消