This commit is contained in:
parent
fe84c73459
commit
1d216288db
1 changed files with 8 additions and 9 deletions
17
lsca.uni.py
17
lsca.uni.py
|
@ -12,7 +12,7 @@ def colorize(x):
|
|||
return x * 17 % 256
|
||||
|
||||
|
||||
def render(row):
|
||||
def render(row, scale):
|
||||
grays = colorize(row)
|
||||
if scale > 1:
|
||||
grays = np.repeat(grays, scale)
|
||||
|
@ -27,14 +27,13 @@ def limit(row): # in-place
|
|||
return row
|
||||
|
||||
|
||||
def initialize():
|
||||
def initialize(width):
|
||||
row = np.zeros(width, int)
|
||||
prev, here = 0, 0
|
||||
value = 0
|
||||
for i in range(width):
|
||||
if np.random.randint(0, 8) == 0:
|
||||
here = np.random.randint(16)
|
||||
row[i] = here
|
||||
prev = here
|
||||
if np.random.randint(8) == 0: # only change values occasionally
|
||||
value = np.random.randint(16)
|
||||
row[i] = value
|
||||
limit(row)
|
||||
return row
|
||||
|
||||
|
@ -63,7 +62,7 @@ print("P2") # magic code for an ascii Portable GrayMap (PGM) file
|
|||
print(width * scale, height * scale)
|
||||
print(255) # maximum color value
|
||||
|
||||
row = initialize()
|
||||
row = initialize(width)
|
||||
|
||||
for i in range(height):
|
||||
# left, center, right:
|
||||
|
@ -81,4 +80,4 @@ for i in range(height):
|
|||
row = diffusion + delta
|
||||
|
||||
limit(row)
|
||||
render(row)
|
||||
render(row, scale)
|
||||
|
|
Loading…
Reference in a new issue