65.9K
CodeProject is changing. Read more.
Home

Heart shaped Form in C# 2.0

starIconstarIconstarIconstarIconstarIcon

5.00/5 (5 votes)

Apr 6, 2011

CPOL
viewsIcon

16413

My alternate uses the AddBezier method, and the size of the heart adjusts to the size of the form.private void Form1_Load(object sender, EventArgs e){ using(System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath()) { path.AddBezier(...

My alternate uses the AddBezier method, and the size of the heart adjusts to the size of the form.
private void Form1_Load(object sender, EventArgs e)
{
    using(System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath())
    {
        path.AddBezier( this.Width >> 1,  
                        this.Height >> 2, 
                        this.Width * 1.25f, 0f, 
                        this.Width, 
                        this.Height * 0.75f, 
                        this.Width >> 1, 
                        this.Height);
        path.AddBezier( this.Width >> 1, 
                        this.Height >> 2, 
                        - this.Width * .25f, 0f,
                        0f, 
                        this.Height * 0.75f, 
                        this.Width >> 1, 
                        this.Height);
        this.Region = new Region(path);
    }
}