From 1d216288dbabf1936c003c6412e42664b25530e5 Mon Sep 17 00:00:00 2001 From: Connor Date: Sat, 19 Jan 2019 23:41:58 -0800 Subject: [PATCH] --- lsca.uni.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lsca.uni.py b/lsca.uni.py index e2ab60f..326eb86 100644 --- a/lsca.uni.py +++ b/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)