Difference between revisions of "C#:Flags with Polygons Tutorial"

From Progzoo
Jump to: navigation, search
(Bahamas)
(Jamaica)
Line 64: Line 64:
 
static void drawFlag(Graphics g)
 
static void drawFlag(Graphics g)
 
{
 
{
   g.FillRectangle(Brushes.Blue,0,0,500,300);
+
   g.FillRectangle(Brushes.Blue,0,0,300,150);
  g.DrawLine(new Pen(Brushes.White,30),0,0,500,300);
+
 
}
 
}
 
]]></prog>
 
]]></prog>
 +
<answer>
 +
static void drawFlag(Graphics g)
 +
{
 +
  g.FillRectangle(Brushes.Yellow,0,0,300,150);
 +
  Point [] tri={new Point(0,15),
 +
                new Point(120,75),
 +
                new Point(0,135)};
 +
  g.FillPolygon(Brushes.Black,tri);
 +
  g.FillPolygon(Brushes.Black,new Point[]
 +
              {new Point(300,15),
 +
                new Point(180,75),
 +
                new Point(300,135)});
 +
  g.FillPolygon(Brushes.Green,new Point[]
 +
              {new Point(30,0),
 +
                new Point(270,0),
 +
                new Point(150,60)});
 +
  g.FillPolygon(Brushes.Green,new Point[]
 +
              {new Point(30,150),
 +
                new Point(270,150),
 +
                new Point(150,90)});
 +
}
 +
</answer>
 
<p>We need to four triangle to draw the flag of Jamaica.
 
<p>We need to four triangle to draw the flag of Jamaica.
 
If we get it right we will leave a yellow cross.</p>
 
If we get it right we will leave a yellow cross.</p>

Revision as of 14:30, 6 March 2013

Drawing flags: filling polygons.

Napier

The Napier flag is a red triangle on a white square. It suggests the letter N.
Flagnapier.png

[Font] [Default] [Show] [Resize] [History] [Profile]

Bahamas

To complete the flag of the Bahamas you must add the black triangle which represents the unity and vigour of the people.

Flagbahamas.png

[Font] [Default] [Show] [Resize] [History] [Profile]

Jamaica

We need to four triangle to draw the flag of Jamaica. If we get it right we will leave a yellow cross.

Flagjamaica.png

[Font] [Default] [Show] [Resize] [History] [Profile]

Seychelles

The Seychelles has a cheerful flag; four triangles and a quadrilateral.

Flagseychelles.png

[Font] [Default] [Show] [Resize] [History] [Profile]