Stars & Stripes

Stars and Stripes

By Monty, 4th July 2015

Stars and Stripes

Stars and Stripes

A variation on the Stars and Stripes American Flag for Independence Day. It’s an exercise in the use of transparency in Pygame. The stripes are made transparent so the stars image behind shows through.

'''     Stars and Stripes
    Just a little July 4th exercise...
    Authour: Alan Richmond, Python3.Codes
import pygame as p

w,h = 1000,624                      # Flag size
y = h/13                            # width of a stripe

d = p.display.set_mode((w,h))

img = p.image.load("stars.jpg").convert()

s = p.Surface((w,y))

rd = p.Color(255,0,0)
wt = p.Color(255,255,255)
c = rd

for i in range(13):

    d.blit(s, (0,y*i))
    if c==rd:   c=wt
    else:       c=rd


The flag of the United States of America, often referred to as the American flag, is the national flag of the United States. It consists of thirteen equal horizontal stripes of red (top and bottom) alternating with white, with a blue rectangle in the canton (referred to specifically as the "union") bearing fifty small, white, five-pointed stars arranged in nine offset horizontal rows, where rows of six stars (top and bottom) alternate with rows of five stars. The 50 stars on the flag represent the 50 states of the United States of America, and the 13 stripes represent the thirteen British colonies that declared independence from the Kingdom of Great Britain, and became the first states in the U.S. Nicknames for the flag include the Stars and Stripes, Old Glory, and the Star-Spangled Banner.

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.