aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-09 10:36:26 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:33:00 +0000
commita3f2e2220ad0448bddb853eca339962f7d64732a (patch)
tree83d27acd40c8012b2468c69dd3bc26e3a7c0d672
parentgenerate-alt-random: emit sixels on the alt screen (diff)
generate-alt-random: 50% chance of overwriting the last sixel
-rwxr-xr-xscripts/generate-alt-random-writes.py20
1 files 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}')