mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
generate-alt-random: 50% chance of overwriting the last sixel
This commit is contained in:
parent
4a86cd7475
commit
a3f2e2220a
1 changed files with 14 additions and 6 deletions
|
|
@ -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}')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue