gpt4 book ai didi

c# - 用渐变颜色绘制一条线

转载 作者:行者123 更新时间:2023-12-03 03:38:31 27 4
gpt4 key购买 nike

是否可以使用渐变颜色画一条线?

我希望能够绘制一条直线或曲线(如果可能),其中线的一端是蓝色,另一端是红色。

此外,每行可能需要多个渐变,例如颜色从蓝色 -> 绿色 -> 红色。我认为这可能只是由绘制在一起的多条渐变线组成。

最佳答案

protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

Graphics graphicsObject = e.Graphics;

using (Brush aGradientBrush = new LinearGradientBrush(new Point(0, 0), new Point(50, 0), Color.Blue, Color.Red))
{
using (Pen aGradientPen = new Pen(aGradientBrush))
{
graphicsObject.DrawLine(aGradientPen, new Point(0, 10), new Point(100, 10));
}
}
}

关于c# - 用渐变颜色绘制一条线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/576861/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com