C# 在c中的graphicspath中添加lineargradientbrush#
您好如何在图形上填充lineargradientbrush..C# 在c中的graphicspath中添加lineargradientbrush#,c#,C#,您好如何在图形上填充lineargradientbrush.. 我有这个代码,solidbrush只能填充它。。我不知道如何用线画笔填充它。。请帮忙 我有这个密码 class KamoteButton : Button { protected override void OnPaint(PaintEventArgs pevent) { int width = this.Width-1; int height = this.Height-1;
我有这个代码,solidbrush只能填充它。。我不知道如何用线画笔填充它。。请帮忙 我有这个密码
class KamoteButton : Button
{
protected override void OnPaint(PaintEventArgs pevent)
{
int width = this.Width-1;
int height = this.Height-1;
Color gradColor_a = Color.FromArgb(162, 177, 183);
Color gradColor_b = Color.FromArgb(104, 111, 114);
int radius = this.Width / 8;
Graphics gFx = pevent.Graphics;
gFx.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath gp = new GraphicsPath();
gp.AddArc(0, 0, radius, radius, 180, 90);
gp.AddLine(width / 8, 0, width - width / 8, 0);
gp.AddArc(width - radius, 0, radius, radius, 270, 90);
gp.AddLine(width, width / 8, width, height - width / 8);
gp.AddArc(width - radius, height - radius, radius, radius, 0, 90);
gp.AddLine(width - width / 8, height, width / 8, height);
gp.AddArc(0, height - radius, radius, radius, 90, 90);
gp.AddLine(0, height - width / 8, 0, width / 8);
Rectangle r = new Rectangle(0, 0, 100, 100);
LinearGradientBrush lbg = new LinearGradientBrush(gp, gradColor_a, gradColor_b, LinearGradientMode.Vertical);
SolidBrush sb = new SolidBrush(Color.Red);
gFx.FillPath(lbg, gp);
this.Region = new Region(gp);
}
}
创建GradientBrush的代码将无法编译:
LinearGradientBrush lbg = new LinearGradientBrush(gp,
gradColor_a, gradColor_b, LinearGradientMode.Vertical);
没有以路径作为参数的构造函数。将其替换为2点或1个矩形那么发生了什么,没有发生什么,以及您期望的是什么?SolidBrush从未使用过。是的。。实心画笔就在那里,只是为了测试只有实心画笔在填充图形。。我只是想了解如何使用lineargradientbrush填充图形的方法……)谢谢,先生。。我在用这个。。LinearGradientBrush lbg=新的LinearGradientBrush(新点(0,0),新点(this.Height,this.Height),渐变色a,渐变色b);