Wallpaper
Shining Carpet VIEW FULLSCREEN - Shining Carpet
Little Hex VIEW FULLSCREEN - Little Hex
Big Hex VIEW FULLSCREEN - Big Hex
Hex in Hex VIEW FULLSCREEN - Hex in Hex
Brick VIEW FULLSCREEN - Brick
Clover VIEW FULLSCREEN - Clover
Skull VIEW FULLSCREEN - Skull
Leaves VIEW FULLSCREEN - Leaves
Overlapping Diamonds VIEW FULLSCREEN - Overlapping Diamond
This piece is based on programs in my free programming book, The Big Book of Small Python Projects: Project 35 - Hex Grid and Project 65 - Shining Carpet. The "wallpaper" style of scroll art displays a static, forever-repeating pattern. While the simplicty makes it less exciting than other forms of scroll art, it is approachable and forces creativity in design. The same short program can display any wallpaper pattern. You only need to change the wallpaper data:
import time
DELAY = 0.4
WIDTH = 80
wallpaper_rows = [ # Change as desired; All rows must be the same length.
r'_ \ \ \_/ __',
r' \ \ \___/ _',
r'\ \ \_____/ ',
r'/ / / ___ \_',
r'_/ / / _ \__',
r'__/ / / \___',
]
x_repeat = WIDTH // len(wallpaper_rows[0])
while True:
# Display each row in wallpaper_rows:
for row in wallpaper_rows:
print(row * x_repeat)
time.sleep(DELAY)
The above produces the hexagon pattern of the carpet in the Overlook Hotel in the 1980 movie, The Shining:
_ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ __
\ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _
\ \ \_____/ \ \ \_____/ \ \ \_____/ \ \ \_____/ \ \ \_____/ \ \ \_____/
/ / / ___ \_/ / / ___ \_/ / / ___ \_/ / / ___ \_/ / / ___ \_/ / / ___ \_
_/ / / _ \___/ / / _ \___/ / / _ \___/ / / _ \___/ / / _ \___/ / / _ \__
__/ / / \_____/ / / \_____/ / / \_____/ / / \_____/ / / \_____/ / / \___
_ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ __
\ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _
\ \ \_____/ \ \ \_____/ \ \ \_____/ \ \ \_____/ \ \ \_____/ \ \ \_____/
/ / / ___ \_/ / / ___ \_/ / / ___ \_/ / / ___ \_/ / / ___ \_/ / / ___ \_
_/ / / _ \___/ / / _ \___/ / / _ \___/ / / _ \___/ / / _ \___/ / / _ \__
__/ / / \_____/ / / \_____/ / / \_____/ / / \_____/ / / \_____/ / / \___
_ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ ___ \ \ \_/ __
\ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _ \ \ \___/ _
By changing the wallpaper_rows
array...
wallpaper_rows = [ # Change as desired; All rows must be the same length.
r'\__ ',
r'/ \__',
r'\ ',
r'/ __',
r'\__/ ',
r'/ ',
]
...you create a brand new wallpaper:
\__ \__ \__ \__ \__ \__ \__ \__ \__ \__ \__ \__ \__
/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__
\ \ \ \ \ \ \ \ \ \ \ \ \
/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __
\__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/
/ / / / / / / / / / / / /
\__ \__ \__ \__ \__ \__ \__ \__ \__ \__ \__ \__ \__
/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__
\ \ \ \ \ \ \ \ \ \ \ \ \
/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __/ __
\__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/ \__/
/ / / / / / / / / / / / /
Tessellations are a natural pattern to create wallpaper scroll art. An internet image search for "tessellations" can provide inspiration, especially if you change the search settings to Line Drawing or Black and White.
The wallpaper program exhibited here contains several different wallpaper patterns which you can select by changing the WALLPAPER
constant to one of the dictionary key values in the WALLPAPERS_PATTERNS
variable.
(It was working on these tessellations that made me learn of a bug in Python where raw strings cannot end with a backslash, even if escaped.)
Links
- Python source code
- JavaScript source code in JSFiddle - Shining Carpet
- JavaScript source code in JSFiddle - Little Hex
- JavaScript source code in JSFiddle - Big Hex
- JavaScript source code in JSFiddle - Hex in Hex
- JavaScript source code in JSFiddle - Brick
- JavaScript source code in JSFiddle - Clover
- JavaScript source code in JSFiddle - Skull
- JavaScript source code in JSFiddle - Leaves
- JavaScript source code in JSFiddle - Overlapping Diamonds