C# Corner Logo: 3D GDI+ Effect


"It's time to redesign the logo. Let's do some 3D work here". That's what Owen said an hour ago. And after that he drew a 3D C# logo on the board.

Hmmm .. I decided to design it in GDI+. 

Actually it wasn't hard at all. Just simple drawing polygons with some color effects. I'm still working on it but here is how C# Corner logo looks like at this moment. After that I decided to write a small game based on C# Corner. It's still a secret.

If you don't know how to use GDI+ brushes, pens, strings, or brushes, I recommend read these two tutorials.

  1. GDI+ Tutorial for Beginners 
  2. Working with GDI+ Brushes 

As you can see from the following code, I simply did nothing but created different brushes and drew three polygons and that's it. Add following namespace to your project and write the code listed below on your form's paint event.

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
// Create a pen and font
Graphics g = e.Graphics;
Pen blackPen =
new Pen(Color.Black, 2);
Font verdanaFont =
new Font( "Verdana", 60, FontStyle.Bold);
// Create points that define polygon.
Point[] curvePoints1 = { new Point(200, 15),
new Point(200, 200), new Point(375, 250) };
Point[] curvePoints2 = {
new Point(0, 250),
new Point(200, 200), new Point(375, 250) };
Point[] curvePoints3 = {
new Point(200, 15),
new Point(200, 200), new Point(0, 250) };
// Create linear gradient brushes
Point pt1 = new Point(10, 10);
Point pt2 =
new Point(30, 30);
LinearGradientBrush lgBrush1 =
new LinearGradientBrush(pt1, pt2, Color.Red, Color.Blue);
LinearGradientBrush lgBrush2 =
new LinearGradientBrush(pt1, pt2, Color.Red, Color.Green);
LinearGradientBrush lgBrush3 =
new LinearGradientBrush(pt1, pt2, Color.Blue, Color.Green);
// If you want to draw three lines
//e.Graphics.DrawLine(blackPen, 200, 55, 200, 200);
//e.Graphics.DrawLine(blackPen, 50, 250, 200, 200);
//e.Graphics.DrawLine(blackPen, 345, 260, 200, 200);
// Set quality of text and shape
g.TextRenderingHint = TextRenderingHint.AntiAlias;
g.SmoothingMode = SmoothingMode.AntiAlias;
// Draw three polygons and string
e.Graphics.FillPolygon(new SolidBrush(Color.FromArgb(80, 255, 0, 0)), curvePoints1);
e.Graphics.FillPolygon(
new SolidBrush(Color.FromArgb(80, 0, 255, 0)), curvePoints2);
e.Graphics.FillPolygon(
new SolidBrush(Color.FromArgb(80, 0, 0, 255)), curvePoints3);
// Draw C# using the DrawString method
// Starting @ point 140, 150
g.DrawString("C#", verdanaFont, lgBrush1, new PointF(140,150) );
// Dispose Graphics
g.Dispose();
}


Similar Articles
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.