五角星填充FillModesClassical


XMarksTheSpot 基类见:http://blog.csdn.net/u013384702/article/details/17883367


Code:(注意两种填充模式的区别)

using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace CsStudy
{
    class FillModesClassical : XMarksTheSpot
    {
        public new static void Main()
        {
            Application.Run(new FillModesClassical());
        }
        public FillModesClassical() {
            Text = "五角星填充";
            ClientSize = new Size(2*ClientSize.Height,ClientSize.Height);
        }
        protected override void DoPage(Graphics grph, System.Drawing.Color clr, int cx, int cy)
        {
            Brush brush = new SolidBrush(clr);
            Point[] apt = new Point[5];

            for (int i = 0; i < apt.Length; i++)
            {
                double dAngle = (i * 0.8 - 0.5) * Math.PI;
                apt[i] = new Point((int)(cx*(0.25+0.24*Math.Cos(dAngle))),
                    (int)(cy * (0.50 + 0.48 * Math.Sin(dAngle))));
            }

            grph.FillPolygon(brush,apt,FillMode.Alternate);//交替填充
            for (int i = 0; i < apt.Length; i++)
                apt[i].X += cx / 2;

                grph.FillPolygon(brush, apt, FillMode.Winding);//环绕填充
        }
    }
}

效果图:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值