You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SI13/RESURGENCE/patterns-generating.ipynb

57 KiB

Patterns (part 1)

Generating patterns

Generating patterns, weaving & textile design.

The structure of a fabric or its weave — that is, the fastening of its elements of threads to each other — is as much a determining factor in its function as is the choice of the raw material. In fact, the interrelation of the two, the subtle play between them in supporting, impeding, or modiying each other's characteristics, is the essence of weaving. (p. 38)

Anni Albers - On Weaving (1965), https://monoskop.org/images/7/71/Albers_Anni_On_Weaving_1974.pdf

Red-Geen Slit Tapestry, Gunta Stölzl (1927/28)

Red-Geen Slit Tapestry, Gunta Stölzl (1927/28)


Re-turning (to): Variables, Lists & Loops

In [5]:
words = ['weaving', 'with', 'words', 'and', 'code']
In [11]:
# First a simple loop through the list
for word in words:
    print(word)
weaving
with
words
and
code
In [21]:
# Then, a loop in which we start to play with random again
import random
for word in words:
    print(random.choice(words), random.choice(words), random.choice(words), random.choice(words), random.choice(words))
code weaving weaving code words
with with and code and
code code weaving and with
and weaving words code and
and with words words weaving
In [24]:
# How to work with more iterations of the loop? 
# For example 100?
# You can use "range"
range?
Init signature: range(self, /, *args, **kwargs)
Docstring:     
range(stop) -> range object
range(start, stop[, step]) -> range object

Return an object that produces a sequence of integers from start (inclusive)
to stop (exclusive) by step.  range(i, j) produces i, i+1, i+2, ..., j-1.
start defaults to 0, and stop is omitted!  range(4) produces 0, 1, 2, 3.
These are exactly the valid indices for a list of 4 elements.
When step is given, it specifies the increment (or decrement).
Type:           type
Subclasses:     
In [26]:
# Make a loop that starts at 0 and ends at 99 (100 iterations)
import random
for number in range(100):
    print(random.choice(words), random.choice(words), random.choice(words), random.choice(words), random.choice(words))
words with and code words
words words and weaving with
and and and and code
words code weaving with weaving
code code code with weaving
and weaving weaving and with
weaving with words with and
and words and weaving and
words weaving code code weaving
code words words with code
weaving with words and code
weaving and and words weaving
and weaving weaving and words
with code weaving weaving and
with words words code with
code with weaving and weaving
weaving weaving weaving with with
weaving and code code with
words weaving and and weaving
weaving words weaving weaving weaving
with and with weaving and
and weaving with code code
code words words and code
weaving weaving weaving words and
and words words with and
and code code code weaving
weaving weaving words weaving with
words and code with code
weaving words and code code
and words words words words
weaving and code code weaving
with with words weaving and
words code weaving weaving code
code words words weaving weaving
words words code code words
words weaving with and and
with and and with and
with code code with words
with code code with words
words words and words code
code weaving words code code
weaving words and with with
with with weaving words and
weaving weaving weaving words code
and and weaving weaving weaving
code words code weaving weaving
with code and and code
with weaving weaving code words
and code weaving words with
and words words weaving weaving
with code with with code
weaving weaving code words words
and and and and words
words with weaving code weaving
words code with with code
code with with code code
and weaving and words code
code code with words and
code code and and words
and with words weaving weaving
with weaving with with and
words and words and with
weaving code words code words
with weaving with words words
weaving words and with and
code words and words and
and weaving weaving code code
with words and code words
with code weaving code code
code words code weaving and
words words code code weaving
weaving code and with and
with weaving with weaving words
with weaving and words and
and weaving words code and
with weaving with and code
weaving words with with words
words with weaving words and
weaving and words words words
with words weaving and and
weaving code weaving and words
weaving words weaving with code
with words and weaving weaving
code words with with code
weaving words words and weaving
and words words with and
and with code weaving code
code weaving words and weaving
with weaving words and and
code weaving and weaving and
with weaving code with weaving
and weaving code code with
and code words weaving words
and words weaving with code
words words weaving words with
code with with code and
words with code and code
code and and words with
with with words weaving and
words with weaving words and
In [44]:
# You can use range also differently, for example to loop in between two numbers ...
for number in range(3,10):
    print(number)
3
4
5
6
7
8
9
In [43]:
# ... or with bigger steps:
for number in range(0,100,10):
    print(number)
0
10
20
30
40
50
60
70
80
90
In [4]:
# Now... write a loop in  a loop
for x in range(1,6):
    for y in range(1,6):
        print('x'*x, 'y'*y)
x y
x yy
x yyy
x yyyy
x yyyyy
xx y
xx yy
xx yyy
xx yyyy
xx yyyyy
xxx y
xxx yy
xxx yyy
xxx yyyy
xxx yyyyy
xxxx y
xxxx yy
xxxx yyy
xxxx yyyy
xxxx yyyyy
xxxxx y
xxxxx yy
xxxxx yyy
xxxxx yyyy
xxxxx yyyyy

ASCII canvas

A not-too-big next step is to start generating patterns.

These varied experiments in articulation are to be understood not as an end in themselves but merely as a help to us in gaining new terms in the vocabulary of tactile language. (On Weaving, Anni Albers (1965))

Anni Albers - Typewriter Studies

In [5]:
# We could replicate Anni's typewriter study now:
width = 100
height = 20
for y in range(height):
    print('sS' * 50)
    print('_' * width)
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________
sSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsS
____________________________________________________________________________________________________

mini-exercise: try to replicate the other typewriter study yourself now!

In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [9]:
# Let's continue a bit with this "canvas-mode" of working, 
# and let's bring the random function to the table again.

# In order to slowly build a canvas of characters, 
# we will use a variable (called 'line' in this case) to temporary save our line ...

import random
characters = ['░','▒','▓','▉','▚','▞']
width = 100
height = 30
line = ''
for y in range(height):
    for x in range(width):
        line += random.choice(characters)
    print(line)
    line = ''
▉▓▞▉▉░░▞▚░▞░▉▚▚▒▓▉▉░░▉▉▞░▓▒▓▞▉▚▒▉▒▓▓▉░▉▞▚░▉▒▞▓▒▞▚▚▉▒▓▓▉▒░▓▉▒▞▓░▉░▒▚░▞▞▒▉░▉▚░▓░▞▚▞▓▞░▓▒▓▞░░▉▉▉▞▚▚▉▞▉░
░▉▓▞▚▞░▉▚▓▞▉▞▉▚▉▚▚▉▓▒▚▓▞░░▞▚░▒▓▞░▓░▚░░▚░▓▓▒▒▓░▚▞▉▉░░▒▚▞▓░▚▉▚▞▚░░▒▓░░▒▉▉▒▉░▓▉░▉▓░▉▞▞▉▉▞░▞▉▚▉░░░▉▓▚░▉▚
░▓▒▉▓▒░▒▓▚▓▚▞▓▚▚▉▚▓▞▉▞▓▒▉▓▉▓░▉▓▓▓▞░▓▚░▚▉▒▞▚▉▓▒▒░▒▚▉░▉▞▓░▓▞▞▚▉▉▉▞░▒░▉░▓▒░░▚▒▓░▚░▒▒░░▓▉▉▓▒▉▉▚░▉▒▒▞▓░▞▓
▚▒▒▓░░▉▞▞▓▉▓▉▓░▚▉░▒▚▓▒▚▒▚▚▚▞▉▉▉▚░▉▚▞▒▚▉▓▉░░▞▚▓▒░▉▉▉▞░▒▉▒▞▚▞▓░▒▉▒▒░▉▉▒▓▓░▒▚░▒▞▉▞▞▚▉░░▚▒▉▒▉▓░░▒▒▉▓▉▚▞▚
▞▞▚▒▓▒▒▞▓▒▚▉▉▓▓▚▚▞▞▚▚▉▓▞▞▒░▓▓▚▓▒▓▓▚▚▚▒▉▉▚▓▉░▓▒▒▓▞▓▒▚▒▚▉░▓▚▉░▉▉░▞▚▞▚▞▒▓░▓░▓▓▚▉▞▞▒▚▞▒▚▞▉▓▞▚▞▓▞▒▉░░▓▓▓▒
░▞▓▒▉▒▒▉▞▚▉▒▓▚▞▒▚▚▓▞▉▒▚▞▓▒▉▞▓▒▓▚▞▞▒░▓░░▞▓▓▚▞▓░▞░▚▚░▒▓▚▒▒▚▒░▉▞▞░░▉▞▒▞▚▓▓░▉▉▞▚▚▞▞▓▒░▞▞▒▚░▓▓▓▉▞▚░░▚░▉▚▞
▒▉▒▒▓░▚▚▉▒▚▒▞▞▓▉▓▉▞▚▉▉▓▒░▒▒░▓▒▚▒▓▓▞▒▓▒▓▚▒░▞▉▉▒░▚░▓░▓▒▓▞▓▓▒▉▉▚▒▞▚▉▉░▚▞▚░▚▓░▉▞▉▚▚▉▞▞▓▒▓▉▓▞▓▓▉▚▉▉▉▒▒▒▒░
▒▒░▓▞▒░▓▉▚▚▓░▓▒▞▉▞▓▉▉▉▒▓▞▞░▓▚▒▓▓▉▉▞░░░▒▚▉▚░░▉▞▒▓▒▚▓▓▚▚▓▉▉▚▚▓░▒▓▒▞▉░▉▓░▞▒▒▞▚▚▓░▚▞▓▒▚░░▒▒▉▞░▒▒▉▞▞▓▉▒▚▉
▞▒▉▓▞▒░▚▞▒░▓▉▚▒▒▉▒▉▒▉░▞▚▒▒▒▉▚▓▚▒░▓▉▞▞░░▒▉▉▒▓▉▞▓▞▞░▒▞▒▚░░▓░▞▓▚▉▓▒▚▞░▓░▚▉▚▚▓▓▓▚▉▉▚▞▒▚▉▞▉▓▒▚▒▉▒░▒▉░▓░░▒
▞▚▞▉▉▚▉▓▞▒▚▒▚▉▞▉▞▒▓▞▒▚▉░▚▓▒▓▚▞▓▒▞▚▞░▞░▒▉▓▞▞▚▒░▓▉▚░▚▚▉▒▓▉▞▓▒▒▒▓▉░░▉▉▚░▓▉▉▞▒▓▚░▒▉▓▞▓▞▉▓▉▒▒▉▒▓▓▒▞░▞▞▚▓░
░▒▓▉▚▉▓▓▓▓░▞▞▚▚▚▞▞▒▓▚░░▉░▞▓▒▓▒▞▒░▓▞▞▒▓▒▒▚▚▓▉▒▉░▚▞▞▚▞▚▓░▉▓░▞▞▞▞▒░░▚▒▒░░▚░▚▚░▒▓▒▓▉░░░▓▚▒▞▚▓▒▒▚▉▒░▓▓▒▉░
▞░▚▞▞▚▚▚▒▒▞▒▒▒▉▞▓▚▉▒▞▚▒▉▒▓░▓░▓▞▚▓▒▚▉▞▞▉░▉▒▓░▞▞▉▉▉░▚░▉▉▉▒▓▉▒▚▒▓▉▞▒▞▓▉▒▓▉▞▚▞▒▚▓▚▚▓▓▞▉▉▒▒▓▒▚▞▚▚▒▞▉▞░▒▒▚
▚▓▒▚▒▚▒▒░▉▒▓▓▒▚▓▓▒░▚▚▚▚▓░░▚░░▞▒▒▉▞▞▒▉░▚▉░░▞▓░▒▞▉▞▉▚▉▓▉░▚▉▉░▒▞▓▒▞▒▚▒▓░▚░▉▚▓▓░▉▉▓▞░░▉▓▓▉░░▞▚▚▒▚▓▒▞▓▉▉▚
▚▒▞░░▓▓░▚▉▒▓▒▞▚▓▉░▞▚▒▚▞▒░▓▉░▞░▞░▒▒▒▞▚▚░▒░▒░▓▞▉▚▚▓▚▚▒▚▒▞░▒░▞▒▒▉▉▉▒▓▉▓░░▓▚▉▞▚▉▞▚▚▒░▚▒▞▞▒▒▒▞░░░░▞▞▚▉▓▓░
▒▓▚░▓░▚░▒░▓▞▒▚▓▓▞░▉▚▞▒▉▓▒▓▒░▚▞▚░▞▚▚░▚░▉░▞▓▞▒▞▓▚▚▒▚▉▞░░▞▓░░▒▓▒▒░▞▞▉▒░▓▒▉▉▚▚░░▉▉▚▞░▓▓▒▉░▚▞▞▓▞▉▓▚▚▚░▉░▒
▓▞▞░░▉▚░░▉▓▒▓▒▞▞▉▒▉▉▒▒░▞▒▒░▚▞▞░░░▉▉▞░▓▉▞▞░▞▞▉▞▉▒▓░▞▉▒▚▉▞░▞▒▉▒▒▞▓▉▞░▓▉▒▚▞▚▒░▓░▚▉▚▞▞▓▚▉▒▚░▚▒▉▓▉░▓▉░░▞▒
░▞▞▉▓▞▒▒▓▒▉▉▚▚▓▉▚▚▉▚▒▚░▓▉▚▓▓▓▞▚▚▚▞▒▚▓▒▉▚░░▓▉▓▓▉▉▒░▞░▞▚▉▓▞▉▓▒▚▉▞▞▒▞▉░▓░▚▓▒░▚░░░▒▒▞▚▞▓░▚▒░░░▉▞▉▒▉▉▉▓▞▚
░▞░▞▓▚▚▚▚▞▚▓▞░▒▓▉▞▚▓▚▚▞▞▞▚▓▉░░▓▞░▞▓▞▉▉▒▞▓▓░░▒▞▚▓▉▚▒▒░▓░▉▒░▓▓▒▚▉▓▞▓▞░░▓▚▉▓▓▞▉▓░░▚▚▉▒▓▓░░▞░▉▒▒▞░▒░▞▞░▚
▓▉▉▉▒▉▞▉░▉░░▒▓▞▉░▓▚▒▞▞▚▚▓▞▒▒░░▒▞▉▒░▉▞▓▉▉▚▓▓░▞▒▉▒▒▉▉▚▞▓▚░▒▉▞░▒▓▒▒▓▚▓░▚▒▞░▒░░▒▓▞▓▉▚▞▞▚▉▞▚▓▞▒▚▞▉▒▉░▓▞░▒
▒░▉▞▚▉▞▚░░▉▉▒▉▚▓▒▒░▒▒▞░▚▒▓░▉░▉▉▚▚▞▉▒▞▚▉▞▓▞▚░▉▒▞▉▒▞▚▞░▚▉▒▒▓░░░▚▉▓▉▞▉░▉▞▞▓▓▞▒▞▉▉▚▒▒▞▞▚▚▚▒▉░▒▞▓▒▚▒▓▉▒▚▓
▉░░▓▚▒▞▒▒▉░▚▉▉░▉▒▒▒░░▞▚▞▓▉▚▓▞▉▉▒▞▉▒▞▒▉▓▞░▞▒▚▒▚▓▓▚▚▚▒▒▓▓▓▞░▓▓▚░▉▉▒▞▓▞▓░▉▞▞▚▓▚░▉▓▚▚▓▓▞▒▉▚▓░░▓▞▒▉▉▞▞░▓▞
▉▓▚▉░▉▓▞▞░▚▒▓▞▉▞▚▉▉░▒▉▉▉▒░▒▒▚░▒▚▒▓▉▚░▚░▉▞▚▉▓▓▞▒▚▉▚▉▚▞▒▉▚▚▚▒░░▞▉▒▓▉▉▚▓▚▉▞▓▞▒▓▓▞▒▚▓▚░░▚▒▒▚░▉▞▒░▓░▉▓▉▒▓
▓▚▒▓▚▉▚▉░▓▚▒▓▚░░▚▒▞░░▒▚▓▓▞░▒▒▚▓░▒▞▉▚░░▚▉▚▒░▒▉▚▉▞▞▞▓▞▉▞▒▚░▚▉▒▚▞▓▚▉░▓▚▚░▒▞░▉▞▒▉▉▞▚▞▓▓▓▒▚▉▚▚▉▒▉░▞▉▚▚░▉▒
▚░▉▓▞░▓▉░▉▞▓▉▓▓▉▉░▚▓▉▞░▓░▚▞▞▚░▓▒▚░▞░▓▚░▞░▓▚▓▉░▞▓▓░▉▒▓▓░▚▓▉▓▞▉▚▒▞▉▚▓▓░░▞▓▚▞▉▓▉▒▓░▉░▉▞░░▞░░▞▒▒▞▚▓▓▉▓▞▞
▒▓▞▉▒▚▞▓▞▉▞▞░▉░▓▞▓░▓▉▞▉▉▓▓▚▞▚▉▓▞▚▚▓▚▒▒▞▚▞▒▞▒▞▒░░▓▉▒▚▉▓▓▓▒▚▞▓▒▞▓▓▒▞░▞▞▞▚▒▉▓▓▚▉▓░▒▞▞▓░▉░▓▞▓▒▞▓▞░▓░▉▚▚▞
░▚▞▚░▒▒▓▞▓▉░▓▚▓▉░▉▒░▉▞░▒▒▞▒▉▓▚▉▞▚▚▒▚░▚▞▓▞░▒▉▚▓▒▒▞▚▉░▞░▉▚░░▞▚▓░▞▚░▒▉▉▉▚▓▓▉▒▞▒▓▚░▉░░▚▞▓▞▞▞▚░▉░▓░▉▉▓▓▞░
▓▚▒░▓▒▞▒░▞▚░▞▉▉▒▞▚▓▞▉▚▓░▞▚▓▓▒▚▞▓▉▚▉▚▒▒▓▒▚░░▉▞▚░▒▞▞▚▓▞▉▓▉▚░▒▒▒▒▚▒▓▞▉▓▚▚▉▒▚░▒▓▉░░░░▉▚▞░▞░░▓░▓▒▚▒░░▓░▚▉
░▞▞▒▒▉▉▉▞▞▓▓▞▞░▒▒▞▚▚▚▚▞▚▚░▚▓▓▓▓▓▒▚▒▒▓▓▉▉▒▞░▚▓░▞▞▉▚▞▉▚▞▒▉▞▓▚░▓░▒▚▚▒▞▓▒▓▓▒▓▚▒▉▓▚▚▓░▓▉░▚▒▉░▓▒░░▞▓▞░▉▚▒▞
▒▚▒▞░▚▉░░▞░▓▞▞▚▉░░▞▞▉▞▓▒▚▉▒▉▓▒▓▒▓▒▞▉▞▚▞▉▞▒▓░▚▉▓▞▒▞▉▉▚▉▉▉▞▓▚▚▞▉▓░▒░▞▒▓▒▚▚▒▓▚▞▓▓▞▞▒▚▉▚▞▞▚▓▞▞▚▚▞▓▚░▉░░▉
▒▉▚▚░▞░░▚▓▞░▉▉▓▓░▓▓▞░▞░▒▚▒▒▉▓▚▞░▒▞▉▉▞▚▉▓▓░▓▚▒▒▒▒▒▚▉▞▚░▉▓▚▞▒░▞▞▒▞▞░▚▓▒▓░▚▚▓▚▞▒▉░▉▉▚░▚▒▚░▞▉▉▒▓▞▓▉▉▒▓▉▚
In [6]:
# A loop in a loop?
width = 10
height = 10
for y in range(height):
    print('x =', x)
    for x in range(width):
        print('      y =', y)
x = 0
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 1
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 2
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 3
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 4
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 5
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 6
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 7
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 8
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
x = 9
      y = 0
      y = 1
      y = 2
      y = 3
      y = 4
      y = 5
      y = 6
      y = 7
      y = 8
      y = 9
In [29]:
# A loop in a loop + collecting characters in a line...
width = 30
height = 20
line = ''
for y in range(height):
    for x in range(width):
        line += str(x) 
    print(line)
    line = '' # try to comment this line out, to see the difference
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
01234567891011121314151617181920212223242526272829
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [10]:
# More patterns, more ways of drawing in this canvas ...
width = 60
height = 20
line = ''
for y in range(height):
    # here i collect all the characters for one line
    line += '-' * width
    line += '+' * width
    
    # print & reset
    print(line)
    line = ''
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
In [ ]:
 
In [17]:
# or another one
width = 20
height = 20
line = ''

for y in range(height):
    
    # here i collect all the characters for one line
    for x in range(width):
        
        # check if the line "number" is odd or even
        # to do this, you can use the "%", called the "modulo"
        if y % 2 == 0:
            line += '???'
            line += '   '
        else:
            line += '   '
            line += '!!!'
            
    # print & reset
    print(line)
    line = ''
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   ???   
   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!   !!!
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [18]:
# Let's also make a pattern that exceeds the width of a single line
# Here, we will first make one long line ...
sentence = 'weaving with words and code'
line = ''
for x in range(100):
    line += sentence
    line += ' ' * x
In [23]:
print(line)
weaving with words and codeweaving with words and code weaving with words and code  weaving with words and code   weaving with words and code    weaving with words and code     weaving with words and code      weaving with words and code       weaving with words and code        weaving with words and code         weaving with words and code          weaving with words and code           weaving with words and code            weaving with words and code             weaving with words and code              weaving with words and code               weaving with words and code                weaving with words and code                 weaving with words and code                  weaving with words and code                   weaving with words and code                    weaving with words and code                     weaving with words and code                      weaving with words and code                       weaving with words and code                        weaving with words and code                         weaving with words and code                          weaving with words and code                           weaving with words and code                            weaving with words and code                             weaving with words and code                              weaving with words and code                               weaving with words and code                                weaving with words and code                                 weaving with words and code                                  weaving with words and code                                   weaving with words and code                                    weaving with words and code                                     weaving with words and code                                      weaving with words and code                                       weaving with words and code                                        weaving with words and code                                         weaving with words and code                                          weaving with words and code                                           weaving with words and code                                            weaving with words and code                                             weaving with words and code                                              weaving with words and code                                               weaving with words and code                                                weaving with words and code                                                 weaving with words and code                                                  weaving with words and code                                                   weaving with words and code                                                    weaving with words and code                                                     weaving with words and code                                                      weaving with words and code                                                       weaving with words and code                                                        weaving with words and code                                                         weaving with words and code                                                          weaving with words and code                                                           weaving with words and code                                                            weaving with words and code                                                             weaving with words and code                                                              weaving with words and code                                                               weaving with words and code                                                                weaving with words and code                                                                 weaving with words and code                                                                  weaving with words and code                                                                   weaving with words and code                                                                    weaving with words and code                                                                     weaving with words and code                                                                      weaving with words and code                                                                       weaving with words and code                                                                        weaving with words and code                                                                         weaving with words and code                                                                          weaving with words and code                                                                           weaving with words and code                                                                            weaving with words and code                                                                             weaving with words and code                                                                              weaving with words and code                                                                               weaving with words and code                                                                                weaving with words and code                                                                                 weaving with words and code                                                                                  weaving with words and code                                                                                   weaving with words and code                                                                                    weaving with words and code                                                                                     weaving with words and code                                                                                      weaving with words and code                                                                                       weaving with words and code                                                                                        weaving with words and code                                                                                         weaving with words and code                                                                                          weaving with words and code                                                                                           weaving with words and code                                                                                            weaving with words and code                                                                                             weaving with words and code                                                                                              weaving with words and code                                                                                               weaving with words and code                                                                                                weaving with words and code                                                                                                 weaving with words and code                                                                                                  weaving with words and code                                                                                                   
In [59]:
# ... and then cut it up into lines of 100 characters, to show the pattern nicely, 
tmp_line = ''
for character in line:
    if len(tmp_line) < 99:
        tmp_line += character
    else: 
        print(tmp_line)
        tmp_line = ''
        count = 0
weaving with words and codeweaving with words and code weaving with words and code  weaving with wo
ds and code   weaving with words and code    weaving with words and code     weaving with words and
code      weaving with words and code       weaving with words and code        weaving with words a
d code         weaving with words and code          weaving with words and code           weaving w
th words and code            weaving with words and code             weaving with words and code   
          weaving with words and code               weaving with words and code                weav
ng with words and code                 weaving with words and code                  weaving with wo
ds and code                   weaving with words and code                    weaving with words and
code                     weaving with words and code                      weaving with words and co
e                       weaving with words and code                        weaving with words and c
de                         weaving with words and code                          weaving with words 
nd code                           weaving with words and code                            weaving wi
h words and code                             weaving with words and code                           
  weaving with words and code                               weaving with words and code            
                   weaving with words and code                                 weaving with words a
d code                                  weaving with words and code                                
  weaving with words and code                                    weaving with words and code       
                             weaving with words and code                                      weavi
g with words and code                                       weaving with words and code            
                           weaving with words and code                                         weav
ng with words and code                                          weaving with words and code        
                                  weaving with words and code                                      
     weaving with words and code                                             weaving with words and
code                                              weaving with words and code                      
                        weaving with words and code                                                
eaving with words and code                                                 weaving with words and c
de                                                  weaving with words and code                    
                              weaving with words and code                                          
         weaving with words and code                                                     weaving wi
h words and code                                                      weaving with words and code  
                                                    weaving with words and code                    
                                   weaving with words and code                                     
                   weaving with words and code                                                     
    weaving with words and code                                                           weaving w
th words and code                                                            weaving with words and
code                                                             weaving with words and code       
                                                      weaving with words and code                  
                                            weaving with words and code                            
                                   weaving with words and code                                     
                           weaving with words and code                                             
                    weaving with words and code                                                    
              weaving with words and code                                                          
         weaving with words and code                                                               
     weaving with words and code                                                                   
  weaving with words and code                                                                      
weaving with words and code                                                                        
eaving with words and code                                                                         
eaving with words and code                                                                         
weaving with words and code                                                                        
  weaving with words and code                                                                      
     weaving with words and code                                                                   
         weaving with words and code                                                               
              weaving with words and code                                                          
                    weaving with words and code                                                    
                           weaving with words and code                                             
                                   weaving with words and code                                     
                                            weaving with words and code                            
                                                      weaving with words and code                  
                                                                 weaving with words and code       
                                                                             weaving with words and
code                                                                                      weaving w
th words and code                                                                                  
    weaving with words and code                                                                    
                   weaving with words and code                                                     
                                   weaving with words and code                                     
                                                    weaving with words and code                    
                                                                      weaving with words and code  
                                                                                         weaving wi
h words and code                                                                                   
         weaving with words and code                                                               
                              weaving with words and code                                          
                                                    weaving with words and code                    
                                                                           weaving with words and c
de                                                                                                 
eaving with words and code                                                                         
                        weaving with words and code                                                
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [20]:
# Try to make some more patterns!
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: