From a3f2e2220ad0448bddb853eca339962f7d64732a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 9 Mar 2021 11:36:26 +0100 Subject: [PATCH] generate-alt-random: 50% chance of overwriting the last sixel --- scripts/generate-alt-random-writes.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 8c49c045..ec671fd3 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -165,9 +165,21 @@ def main(): # The sixel 'alphabet' sixels = '?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' + last_pos = None + last_size = None + for _ in range(100): - # Offset image - out.write(' ' * (random.randrange(cols // 2))) + if last_pos is not None and random.randrange(2): + # Overwrite last sixel. I.e. use same position and + # size as last sixel + pass + else: + # Random origin in upper left quadrant + last_pos = random.randrange(lines // 2) + 1, random.randrange(cols // 2) + 1 + last_size = random.randrange(height // 2), random.randrange(width // 2) + + out.write(f'\033[{last_pos[0]};{last_pos[1]}H') + six_height, six_width = last_size # Begin sixel out.write('\033Pq') @@ -179,10 +191,6 @@ def main(): # (except 'hue' which is 0..360) out.write(f'#{idx};2;{random.randrange(101)};{random.randrange(101)};{random.randrange(101)}') - # Randomize image width/height - six_height = random.randrange(height // 2) - six_width = random.randrange(width // 2) - # Sixel size. Without this, sixels will be # auto-resized on cell-boundaries. out.write(f'"1;1;{six_width};{six_height}')