You are on page 1of 6

Anum Kibria, Reg #550, Syn B

LAB TASK#1

DELIVERABLES: to draw basic shapes

 LINE:
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg; //fg is the name of canvass
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,3); //3 is the width
fg.DrawLine(mypen,0,0, 80, 100); //end points
}
OUTPUT:

 RECTANGLE
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,3);
fg.DrawRectangle(mypen, 20, 20, 60, 80); //co-
ordinates,width,height }

OUTPUT:
 LINE AS DIAGONAL OF RECTANGLE:
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,3);
fg.DrawLine(mypen, 20,20, 80, 100);
fg.DrawRectangle(mypen, 20, 20, 60, 80);
}
OUTPUT:

 CIRCLE:
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,3);
fg.DrawEllipse(mypen, 30, 30, 50, 50);

}
OUTPUT:

 ELLIPSE:
private void Form1_Click(object sender, EventArgs e)
{ Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,3);
fg.DrawEllipse(mypen, 30, 30, 80, 40);
}

OUTPUT:
 FILLED RECTANGLE AND ELLIPSE:
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,3);
SolidBrush b = new SolidBrush(Color.Olive);//we
create solid brush for filling
fg.FillRectangle(b, 30, 30, 70, 30);
fg.FillEllipse(b, 60, 70, 60, 30);
}
OUTPUT:
 DISPLAYING A STRING:
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg;
fg = this.CreateGraphics();
SolidBrush b = new SolidBrush(Color.Olive);
fg.DrawString("anum", new Font("arial", 12), b, 50, 70);
}
OUTPUT

DRAWING A CUBE:
private void Form1_Click(object sender, EventArgs e)
{
Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,2);
SolidBrush b = new SolidBrush(Color.Olive);
fg.FillRectangle(b, 40, 20, 60, 40);
fg.DrawRectangle(mypen, 20, 40, 60, 40);
fg.DrawLine(mypen, 40, 20, 20, 40);
fg.DrawLine(mypen, 100, 20, 80, 40);
fg.DrawLine(mypen, 40, 60, 20, 80);
fg.DrawLine(mypen, 100, 60, 80, 80);

}
OUTPUT:
 MAKING OTHER SHAPES WITH BASIC SHAPES
private void Form1_Click(object sender, EventArgs e)
{ Graphics fg;
fg = this.CreateGraphics();
Pen mypen = new Pen(Color.Magenta,2);
SolidBrush b = new SolidBrush(Color.Olive);
fg.DrawEllipse(mypen, 10, 40, 60, 30);
fg.DrawEllipse(mypen, 10, 120, 60, 30);
fg.DrawLine(mypen, 10, 55, 10, 135);
fg.DrawLine(mypen, 70, 55, 70, 135);
fg.DrawString("PEPSI", new Font("complex", 12), b, 10,80);
}
OUTPUT:

You might also like