ARTICLE

Posted by | April 22, 2011
This article shows how you can draw an ellipse in a different-different size of gradient. This size you can give when creating a rectangle.

Here I mainly use four different sizes of gradient using the rectangle.

• 150
• 75
• 38
• 15

I use the size of the ellipse as 150, so in the first gradient size it will divide two colors (viz. Red & Blue) in equal size.

The main code for first type of size:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyBlog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Rectangle myGradientRectangle = new Rectangle(10, 10, 150, 150);

{
{
}
}

}
}
}

Output of the above code looks like the below image :

In the second size it will divide a rectangle in two equal sizes & each size of rectangle again divides into two equal sizes (viz. Red & Blue).

Main code :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MyBlog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Rectangle myGradientRectangle = new Rectangle(10, 10, 75, 75);

{
{
}
}

}
}
}

Output of the above code looks like the image shown below:

The third size will divide the rectangle into four equal sizes & each size of rectangle is again divided into two equal sizes (viz. Red & Blue).

Main code :

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace MyBlog

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Rectangle myGradientRectangle = new Rectangle(10, 10, 37, 38);

{

{

}
}

}
}
}

The output of the above code looks like the image below:

The third size will divide a rectangle into ten equal sizes & each size of rectangle is again divided into two equal sizes (viz. Red & Blue).

Main code :

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace MyBlog

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Rectangle myGradientRectangle = new Rectangle(10, 10, 15, 15);

{

{

}

}

}

}

}

The output of the above code looks like the image shown below: