Tag Archives: beginner

How to Draw the Malawian Flag

12 Dec

This is one a series of posts on how to draw world flags. Finding the specifications for these flags, and attempting to reproduce the flag perfectly, according to the specifications, is a great way to teach yourself basic graphics programming.

Previously: South Korea

I’m doing the flag of Malawi as a special request from a Processing student who lives there. This is a relatively new flag, having first been adopted in July 2010. Wikipedia tells me that Malawi is one of the world’s least developed countries, with an economy heavily based on agriculture. It is fitting then that their flag features the Sun, which brings energy, poverty, feast and famine. Wikipedia says the sun represents the economic progress made in Malawi since becoming independent.

The Wikipedia specification doesn’t provide too much info about the shapes used in the flag, so I gleaned most of the information I needed by taking a close look at the SVG provided in the article. From this I got the colors, and I figured out that the disc of the sun is exactly 4/15th’s the height of the flag.

I used the Geomerative library to convert the bezier curve of a single ray (the one pointing straight down) to code.

    beginShape();
      vertex(-1,98);
      vertex(1,98);
      bezierVertex(1,98,7.3,165,0,165);
      bezierVertex(-7.3,165,-1,98,-1,98);
    endShape();

The coordinates of this array assume that 0,0 is the center of the sun, and that the flag is 900 x 600 pixels. I use a scale statement to get each ray to the correct size for the flag being drawn:

scale(height/600.0);

In other words, if I’m drawing a flag that is 300 high, it will scale 300/600 or 1/2 the height of the original ray. I use a loop to draw 45 similar rays around the sun, using the rotate command to get each ray into the correct position.