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()
d.blit(img,(0,0))

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

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

for i in range(13):

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

p.display.flip()
p.image.save(d,'Stars-Stripes.png')
Wikipedia:

The flag of the United States, 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

%d bloggers like this: