Skip to content

GDI+ [creating trapezium in main (I created an instance)]

karhong karhong

Asked Jul 13, 2008, 11:17 PM EDT1 answer
Share
LinkedInX

Hi,

 

I wanted to know how do I create the exact polygon(trapezium) in my main form.

I've now created a class "PolygonShape" and inside there is this code(this is a shape of a trapezium):

 

Java
protected override void OnPaint(PaintEventArgs pe)
{



   // Create pen.
   Pen blackPen = new Pen(Color.Black, 3);
   // Create points that define polygon.
   Point point1 = new Point(0, 0);
   Point point2 = new Point(0, 50);
   Point point3 = new Point(150, 50);
   Point point7 = new Point(70, 0);
   Point[] curvePoints =
   {

      point1,

      point2,

      point3,

      point7

Code
   };
   // Draw polygon to screen.
   pe.Graphics.DrawPolygon(blackPen, curvePoints);


}

 

 

Then in my main, I've initialize as below and I created an instance of it

 

Code
PolygonShape poliA = new PolygonShape();
poliA.Width = 100;  //(this width and height turn out to be a rectangle)
poliA.Height = 50;
poliA.BackColor = Color.Azure;

 

P/S  :  i know why it turn out to be rectangle... but i don't know how to make it to follow the design at top when displaying it..

 

 

PROBLEM : when i run this code, then it will come out with a rectangle shape.I've alread tried to research.. but i dont get any ways to make the shape become the shape of the trapezium. Any idea?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    For easier to understand what i'm going to do.

     

    I wanted to make

     

    x.Width

    x.Height

     

    to be a shape of trapezium... I'm wondering whether I'm able to put the shape into it or not (for the instance of my object)

    0