C# 利用GraphicsPath 画螺旋桨控件

今天第一次写博客,也不知道写什么。写的不好,请大家不要见外,前几天看到一个利用C#画太极的控件。我也就跟着做了一个:

                                 

基本的核心代码就是:

                Brush blue = new SolidBrush(Color.Black);//定义黑色笔刷
                Brush red = new SolidBrush(Color.White);//定义白色笔刷
                GraphicsPath leftPath = new GraphicsPath();//初始化路径
                GraphijibencsPath rightPath = new GraphicsPath();//初始化路径
                //定义左边的路径(黑色部分)
                leftPath.AddArc(0, 0, ClientRectangle.Width, ClientRectangle.Width, 0,180);           
                leftPath.AddArc(0, ClientRectangle.Width/4, ClientRectangle.Width / 2, ClientRectangle.Width / 2, 0, - 180 );
                leftPath.AddArc(ClientRectangle.Width / 2, ClientRectangle.Width / 4, ClientRectangle.Width / 2, ClientRectangle.Width / 2, 0, 180);
                    //定义右边的路径(白色部分)
                rightPath.AddArc(0, 0, ClientRectangle.Width, ClientRectangle.Width, 0, -180 );
                rightPath.AddArc(0, ClientRectangle.Width / 4, ClientRectangle.Width / 2, ClientRectangle.Width / 2, 0, - 180);
                rightPath.AddArc(ClientRectangle.Width / 2, ClientRectangle.Width / 4, ClientRectangle.Width / 2, ClientRectangle.Width / 2, 0,  180);
                //填充左边部分
                g.FillPath(blue, leftPath);
                g.FillPie(red, new Rectangle(ClientRectangle.Width * 90 / 400, ClientRectangle.Width * 190 / 400, ClientRectangle.Width * 50 / 400, ClientRectangle.Width * 50 / 400), 0, 360);//填充眼睛
                //填充右边部分
                g.FillPath(red, rightPath);
                g.FillPie(blue, new Rectangle(ClientRectangle.Width * 290 / 400, ClientRectangle.Width * 190 / 400, ClientRectangle.Width * 50 / 400, ClientRectangle.Width * 50 / 400), 0, 360);//填充眼睛

突发奇想就做了一个船舶螺旋桨的控件。加入自己的一些内容,可以实现转动的效果,但是一直觉得效果不是很好!也希望有高手有没有做过转动的效果的控件。多多交流!

                                    

posted on 2011-04-19 14:26  红桃A  阅读(2613)  评论(1编辑  收藏  举报