Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
Programming

Tutorial: Filling polygons

 
Drawing flags: filling polygons.

1. Napier


Big

The Napier flag is a red triangle on a white square. It suggests the letter N.
Napier logo: red triangle in lower left corner on a white square

We create a polygon in order to fill it. The Polygon class is part of the standard awt package. We create a polygon then add points to it as required.

2. Bahamas


Big

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

Flag of the Bahamas.

3. Jamaica


Big

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

Flag of Jamaica: Yellow background, green triangles top and bottom, black triangles left and right.

Each triangle must be given a different name - you can choose your own names or call them ttri, btri, ltri and rtri (for top, bottom, left and right).

4. Seychelles


Big

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

Flag of Seychelles.

We tire of coming up with names for our polygons. In this example we reuse the same old polygon - we reset it after it has done its job.