【问题标题】:Hard to explain, angle and rectangle involved难以解释,涉及角度和矩形
【发布时间】:2011-06-04 09:58:15
【问题描述】:

我有一个矩形和一个角。我需要在 C# 中提供 LinearGradientBrush 的起点和终点,以便 gradient 始终完全适合此矩形,并且永远不会低于或过度扩展矩形。

你们中的一些数学家可以帮助我吗?我确信有一个非常简单的解决方案。

【问题讨论】:

  • 问题太模糊,无法回答。目前尚不清楚角度与问题相关的位置。
  • @Tom W:实际上,我确切地知道这是什么意思。如果渐变旋转,您必须考虑起点和终点以及它们应该放置的位置。

标签: c# wpf gradient trigonometry


【解决方案1】:

以下是否有效(我无法测试):

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

【讨论】:

  • 谢谢,我真的应该检查接受角度的过载。 new LinearGradientBrush(new Rectangle(0,0,Width,Height), Color.Red, Color.Black, myAngle);完美运行
猜你喜欢
  • 2016-02-08
  • 1970-01-01
  • 1970-01-01
  • 2018-11-22
  • 2020-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多