# Examples¶

## The UK Union Flag¶

The following code will produce an SVG file of the British flag:

```import math
import omnicanvas

def create_union_flag(height):
# The union flag is twice as wide as it is high
canvas = omnicanvas.Canvas(height * 2, height, background_color="#000066")

#This is the length of the diagonal of the flag, with Pythagoras
diagonal_length = math.sqrt((height ** 2) + ((height * 2) ** 2))

# This is the angle of the diagonal strips from the horizontal
# tan(θ) = opposite / adjacent, so θ = atan(opposite / adjacent)
diagonal_angle = math.degrees(math.atan((height / 2) / height))

# Add The diagonal white strips
height - (height * 0.1),
(height / 2) - (diagonal_length / 2),
height * 0.2,
diagonal_length,
line_width=0,
rotation=(
height, height / 2, 270 + diagonal_angle
)
)
height - (height * 0.1),
(height / 2) - (diagonal_length / 2),
height * 0.2,
diagonal_length,
line_width=0,
rotation=(
height, height / 2, 90 - diagonal_angle
)
)

# Add diagonal red strips - these'll be partly covered by the white cross
height - (height / 15),
(height / 2) - (diagonal_length / 2),
height / 15,
diagonal_length / 2,
line_width=0,
fill_color="#CC0000",
rotation=(
height, height / 2, 90 - diagonal_angle
)
)
height - (height / 15),
(height / 2) - (diagonal_length / 2),
height / 15,
diagonal_length / 2,
line_width=0,
fill_color="#CC0000",
rotation=(
height, height / 2, 270 - diagonal_angle
)
)
height - (height / 15),
(height / 2) - (diagonal_length / 2),
height / 15,
diagonal_length / 2,
line_width=0,
fill_color="#CC0000",
rotation=(
height, height / 2, 270 + diagonal_angle
)
)
height - (height / 15),
(height / 2) - (diagonal_length / 2),
height / 15,
diagonal_length / 2,
line_width=0,
fill_color="#CC0000",
rotation=(
height, height / 2, 90 + diagonal_angle
)
)

height - (height / 6),
0,
height / 3,
height,
line_width=0
)
0,
(height / 2) - (height / 6),
height * 2,
height / 3,
line_width=0
)

height - (height / 10),
0,
height / 5,
height,
line_width=0,
fill_color="#CC0000",
)