Skip to content

The RoC Flag Drawing Program

History

The flag of Taiwan, also known as the Republic of China (ROC), was first adopted on October 28, 1928.

The design of the sun emblem was created by Lu Hao-tung, a martyr of the Chinese revolution, in 1895. The combination of the blue sky and white sun symbol was later used by the Kuomintang (KMT), also known as the Nationalist Party, which played a crucial role in the Xinhai Revolution that overturn the governance of Qing Dynasty.

After the Chinese Civil War, the ROC government retreated to Taiwan in 1949, while the People's Republic of China (PRC) was established on the mainland. This flag is used as the official flag of Taiwan. It represents a symbol of the ROC government and its historical legacy.

Design

The flag consists of a red field with a blue canton bearing a white sun with twelve triangular rays. This design is known as the "Blue Sky with a White Sun".

The three color used in this flag, blue, white, and red, represent liberty, equality and fraternity, identical with many other national flags (like the American and the French flag).

The twelve rays of the sun symbolize the twelve months and the twelve traditional Chinese hours, each ray representing brightness and progress.

Program

This Python program utilizes Matplotlib, a versatile plotting library, to visually recreate the flag of the RoC (Taiwan).

1. Setting Up the Environment:

The program begins by importing necessary libraries and configuring the plotting environment to ensure high-resolution output.

2. Constructing Flag Elements:

Two rectangles are defined using Matplotlib's Rectangle class, representing the red base and the blue box on the RoC flag respectively.

3. Adding Shapes and Symbols:

Shapes such as rectangles are added to the plot to construct the base design of the flag. The sun and its rays are calculated and drawn using geometric calculations and polygons.

4. Drawing Sun and Rays:

The sun and its rays are drawn using polygons (patch.Polygon()) and circles (plt.Circle()), following precise calculations for positioning and sizing.

5. Final Adjustments and Display:

The plot limits (ax.set_xlim() and ax.set_ylim()), along with hiding axis labels (ax.axis('off')), ensure the flag is displayed correctly without unnecessary clutter.

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patch

# Set the resolution for saved figures and displayed figures
plt.rcParams['savefig.dpi'] = 300
plt.rcParams['figure.dpi'] = 300

# Create two rectangle elements: one red (base) and one blue (box on the top left)
a = patch.Rectangle((0, 1), width=9, height=6, facecolor='#FE0000', edgecolor=None)
b = patch.Rectangle((0, 4), width=4.5, height=3, facecolor='#000095', edgecolor=None)

# Create a figure and axis to plot the shapes
fig, ax = plt.subplots()
ax.add_patch(a)  # Set up the red rectangle
ax.add_patch(b)  # Add the blue box to the flag

# Define coordinates and sizes for sun and rays
radius = 4.5 / 8
radius_blue_circle = radius * 1.075
sunshine = 4.5 / 4

# Draw 12 sunshines
for i in range(0, 12):
    x_1 = 2.25 + sunshine * np.cos(i * np.pi / 6)
    y_1 = 5.5 + sunshine * np.sin(i * np.pi / 6)
    x_2 = 2.25 + sunshine * np.cos(i * np.pi / 6 + np.pi * 5 / 6)
    y_2 = 5.5 + sunshine * np.sin(i * np.pi / 6 + np.pi * 5 / 6)
    x_3 = 2.25
    y_3 = 5.5
    ax.add_patch(patch.Polygon([[x_1, y_1], [x_2, y_2], [x_3, y_3]], fill=True, closed=True, color='white'))

# Draw the blue ring inside the sun
blue_circle = plt.Circle((2.25, 5.5), radius=radius_blue_circle, color='#000095', fill=True, linewidth=0)
ax.add_artist(blue_circle)

white_circle = plt.Circle((2.25, 5.5), radius=radius, color='white', fill=True, linewidth=0)
ax.add_artist(white_circle)

# Set the limits for the x and y axis and remove the axis
ax.set_xlim(0, 9)
ax.set_ylim(1, 7)
ax.axis('off')

# Display the plot
plt.show()
Hidden output