Call me Sheldon – Fun with Flags

I am always looking for new Visio shapes and I found a collection of Flags  in SVG format. They are not complete and some of them lack the actual embellishments on the flags, but it is a start. Though not quite a one stop shop as this page is, I did find some more detailed SVGs by Googling “FLAG country-name SVG”. This took me to more detailed shapes. So, I started converting/making Visio shapes.

SVG is a good starting point for creating Visio shapes, but it has it’s limits. Some are by the nature of SVG and some are by decisions of the shape creator. So, now I have almost 200 country flags as Visio shapes. So why Visio shapes rather than just clip-art? With real Visio shapes, they can stretch. So you can have a tiny flag or a huge one. Enlarging clip art can result in jaggies. Unfortunately, not all the flags are perfect. This is a rundown of some of the issues.

So, creating a flag is easy. The simplest is the surrender flag, a simple white rectangle. You do not even have to worry about the aspect ratio. … but it is not a country flag. The next easiest would be Japan, a red circle on a white rectangle. It is just a matter of getting the right colour of red, the aspect ratio (height to width) of the flag and the ratio of the diameter of the circle to the width of the flag.

Then comes the two colour flags like Poland, a rectangle split in half. This can easily be created by a red rectangle and a white rectangle. As long as you use a grid line to position the shapes, it is no problem to join them with no overlaps or gaps. There are a number of other two colour flags, but they have embellishments (like Malta) or crosses (like Finland) where in addition to the colour and aspect ratio, you need to know the thickness of the lines in the cross. Another way to create the two colour flag is to create the rectangle of the full flag, create a line bigger than the shape, align them so the line is centered and then fragment. For a simple two colour shape, this is over kill, but the technique is useful on flags with more stripes. This is also a useful technique if the dividing line is at an angle (like Jamaica – though again, you need to know the width of the stripe).

The tricolour flags can be created by the same rectangle and line technique, but this time you will need four parallel lines. So duplicate a line three times align on the edge, distribute the lines and then group. Resize the group so it matches the rectangle and make sure that the line ends extend beyond the rectangle. select both shapes and align. Though not necessary, you should select the top and bottom line from the group and delete them. This is just in case your group and rectangle are not the same size and you do not want slivers. Select the rectangle and grouped lines and fragment. You will now have three adjacent rectangles you can colour. Finish off by grouping the flag.

So far we have yet to use SVG files except to determine colours and aspect ratios.

For flags like the US, do the same thing with the lines. I will talk about the star field later. With multiple strips, you have the option of replacing the individual lines of one colour with a single rectangle of that colour the size of the flag to use as a background. The alternate colour will hide portions of the flag to make it appear that the other colour is striped rather than solid.

So, that is some of the basics for creating flags, but before we look further, we should establish some guidelines. What size should the flags be? Flags have various aspect ratios, so the common property I am going to standardize on is a height of one inch. If they are true Visio shapes, then holding the Ctrl key and stretching should not be a problem. The next guideline is to minimize the shapes. Some flags have crosses, there is no need to have two rectangular shapes to create the crosses. Some flags seem to have bands that appear to be a colour stripe centered on top of another coloured stripe. Kenya is an example of this, a red stripe on top of a white stripe. This can be handled by three separate rectangles or a rectangle on top of a bigger rectangle. Which is my preferred solution. It is one less shape.

The SVG shapes are close, but not perfect. Either by SVG limitations or the designer, there are problems. Some of the shapes distort on stretching, and are made up of more basic shapes than are necessary. Some even have cross shape references that also distort the shape. The first clean up step is to  ungroup the shape, and then ungroup the shape… until there are no more groups, just individual shapes. Following Visio Guys recommendation, the result will be rebuilt as a single group. -> Minimize groups, minimize shapes.

The Union Jack is an interesting shape, and appears in several flags of the Commonwealth. So, I will start with converting one of the SVG versions to a proper Visio shape.  One problem with this SVG version of the shape is that the diagonals are made of 1d shapes, so the ends are not clean. Rather than match the flag outline, the line ends are at 90 degrees to the line. So, all the lines have to be replaced by rectangles and the resulting shape trimmed with a rectangle the size of the flag. When finished, we will have a basic Union Jack that can be used in other flags.

The Union Jack has a width of 60 units and a height of 30 units. Each blue corner is 25 units by 10 units. The white cross is 10 units and the red cross is 6 units. The white diagonals are 6 units. and the red diagonals are 2 units.

One thing that people find out when they try and draw the Union Jack is that the red diagonals are not centered. So, you can actually have a Union Jack upside down. So, if you divide the white diagonals from the top left in to six strips, then the 2nd and 3rd strip will be red. The red strip is not continuous over the center, it switches. When you cross the center, it is the 4th and 5th strip that are red. Going from the bottom left, it is still the 2nd and 3rd strip as red and 4th and 5th after the center.

So, a Union Jack flown properly and not in distress mode will have the large white stripe at the top next to the flag pole. If you can not cheat and use an Australian flag as a reference, all flags  that are meant to be raised on a flagpole will have a toggle on the top side of the flag so it can be attached to the rope that will haul the flag up and the bottom side will have a rope to secure the bottom end of the flag to the rope that hauls the flag up.

The stars in the SVGs were interesting. They were made up of triangles. I did try Union on the triangles, but that left gaps. So, it was a matter of selecting the shapes and doing a fragment. reselect the shapes and do Union. Selecting the shapes may be tricky because it may include the background. You need to start the selection property outside the flag and drag across making sure you do not select unnecessary shapes. When dealing with flags like the US that have a field of stars, you can select the entire star field and do a fragment, reselect and do a union.

Crescents were another group of shapes that were made of a collection of simple shapes. In this case, circles. These can be selected, fragmented and the excess shapes deleted. Remember the idea is to minimize the number of shapes for performance.

So, the collection I have got it is not perfect. I have not verified all the colours used or whether the aspect ratios are correct, but it is a start. I have put a sample of the flags in the MSDN Gallery. I am not sure what I will do with the full collection, but I am hoping at some point Microsoft will have a store for Visio shapes and stencils.


John Marshall… Visio MVP

Published by johnvisiomvp

The original Visio MVP. I have worked with the Visio team since 1993