这是画一个立体感的圆柱代码,自己组织下:
private void TestForm_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DrawVertPipe(e.Graphics);
}
private void DrawVertPipe(System.Drawing.Graphics g)
{
System.Drawing.Drawing2D.GraphicsContainer gCon;
gCon = g.BeginContainer();
Rectangle bound=new Rectangle(50,50,50,50);
GraphicsPath gp = new GraphicsPath();
g.SmoothingMode = SmoothingMode.AntiAlias;
gp.AddRectangle(bound);
g.FillPath(new SolidBrush(Color.Violet),gp);
FillCylinderShadow(g,gp,0.5f,Color.FromArgb(100, 0, 0, 0),Color.FromArgb(100, Color.White));
gp.Dispose();
g.EndContainer(gCon);
}
public void FillCylinderShadow(Graphics g,GraphicsPath gp,float focus,Color BeginColor,Color EndColor)
{
LinearGradientBrush linGrBrush = new LinearGradientBrush(
gp.PathPoints[0],gp.PathPoints[1],
BeginColor,
EndColor
);
linGrBrush.SetSigmaBellShape(focus);
g.FillPath(linGrBrush, gp);
linGrBrush.Dispose();
}
浙公网安备 33010602011771号