From add30a38f3aaa702c065ed0e267f72371df24313 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 6 Mar 2021 21:20:11 +0100 Subject: scripts: generate-alt-random: sixel: emit DECGRI - Repeat Character --- scripts/generate-alt-random-writes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 2e51082b..6e7b25ab 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -184,17 +184,18 @@ def main(): six_width = random.randrange(width // 2) # Sixel size. Without this, sixels will be - # auto-resized on cell-boundaries. We expect programs - # to emit this sequence since otherwise you cannot get - # correctly sized images. + # auto-resized on cell-boundaries. out.write(f'"0;0;{six_width};{six_height}') for row in range(six_height // 6): # Each sixel is 6 pixels # Choose a random color out.write(f'#{random.randrange(256)}') - for col in range(six_width): - out.write(f'{random.choice(sixels)}') + if random.randrange(2): + for col in range(six_width): + out.write(f'{random.choice(sixels)}') + else: + out.write(f'!{six_width}{random.choice(sixels)}') # Next line out.write('-') -- cgit v1.3 From eee216f5feef19ac51c11cd55e64d141f7612a70 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 7 Mar 2021 16:52:53 +0100 Subject: generate-alt-random: sixel: pan/pad must not be 0 --- scripts/generate-alt-random-writes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 6e7b25ab..2513cbe9 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -185,7 +185,7 @@ def main(): # Sixel size. Without this, sixels will be # auto-resized on cell-boundaries. - out.write(f'"0;0;{six_width};{six_height}') + out.write(f'"1;1;{six_width};{six_height}') for row in range(six_height // 6): # Each sixel is 6 pixels # Choose a random color -- cgit v1.3 From f8e51fcb178924dd63c2ce185b1b1ab5daa09362 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 7 Mar 2021 17:31:42 +0100 Subject: generate-alt-random: emit multiple sixel bands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures we’re getting the ‘$’ command PGO:d --- scripts/generate-alt-random-writes.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 2513cbe9..770ba038 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -165,7 +165,7 @@ def main(): # The sixel 'alphabet' sixels = '?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~' - for _ in range(200): + for _ in range(100): # Offset image out.write(' ' * (random.randrange(cols // 2))) @@ -188,17 +188,24 @@ def main(): out.write(f'"1;1;{six_width};{six_height}') for row in range(six_height // 6): # Each sixel is 6 pixels - # Choose a random color - out.write(f'#{random.randrange(256)}') - - if random.randrange(2): - for col in range(six_width): - out.write(f'{random.choice(sixels)}') - else: - out.write(f'!{six_width}{random.choice(sixels)}') - - # Next line - out.write('-') + band_count = random.randrange(32) + for band in range(band_count): + # Choose a random color + out.write(f'#{random.randrange(256)}') + + if random.randrange(2): + for col in range(six_width): + out.write(f'{random.choice(sixels)}') + else: + out.write(f'!{six_width}{random.choice(sixels)}') + + # Next line + if band + 1 < band_count: + # Move cursor to beginning of current row + out.write('$') + elif row + 1 < six_height // 6: + # Newline + out.write('-') # End sixel out.write('\033\\') -- cgit v1.3 From 4a86cd7475f43c5bc44c3309a9caa7bd1ee5a453 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 11:35:31 +0100 Subject: generate-alt-random: emit sixels on the alt screen --- scripts/generate-alt-random-writes.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 770ba038..8c49c045 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -158,8 +158,8 @@ def main(): reset_actions = ['\033[m', '\033[39m', '\033[49m'] out.write(random.choice(reset_actions)) - # Leave alt screen - out.write('\033[m\033[r\033[?1049l') + # Reset colors + out.write('\033[m\033[r') if opts.sixel: # The sixel 'alphabet' @@ -210,6 +210,9 @@ def main(): # End sixel out.write('\033\\') + # Leave alt screen + out.write('\033[?1049l') + if __name__ == '__main__': sys.exit(main()) -- cgit v1.3 From a3f2e2220ad0448bddb853eca339962f7d64732a Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 11:36:26 +0100 Subject: generate-alt-random: 50% chance of overwriting the last sixel --- scripts/generate-alt-random-writes.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'scripts') 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}') -- cgit v1.3 From 0bc98877f35ef56e127aecc3df3aff986a4c3c93 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 11:36:56 +0100 Subject: generate-alt-random: emit “Set Raster Attributes” before color definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/generate-alt-random-writes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index ec671fd3..30b7e9c9 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -184,6 +184,10 @@ def main(): # Begin sixel out.write('\033Pq') + # Sixel size. Without this, sixels will be + # auto-resized on cell-boundaries. + out.write(f'"1;1;{six_width};{six_height}') + # Set up 256 random colors for idx in range(256): # param 2: 1=HLS, 2=RGB. @@ -191,10 +195,6 @@ def main(): # (except 'hue' which is 0..360) out.write(f'#{idx};2;{random.randrange(101)};{random.randrange(101)};{random.randrange(101)}') - # Sixel size. Without this, sixels will be - # auto-resized on cell-boundaries. - out.write(f'"1;1;{six_width};{six_height}') - for row in range(six_height // 6): # Each sixel is 6 pixels band_count = random.randrange(32) for band in range(band_count): -- cgit v1.3 From 660a7f9345f83c0ea3b1b92ec98d3ab5cbc06e7e Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 11:37:35 +0100 Subject: generate-alt-random: don’t skip that last partial row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/generate-alt-random-writes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 30b7e9c9..93a542a7 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -180,6 +180,7 @@ def main(): out.write(f'\033[{last_pos[0]};{last_pos[1]}H') six_height, six_width = last_size + six_rows = (six_height + 5) // 6 # Round up; each sixel is 6 pixels # Begin sixel out.write('\033Pq') @@ -195,7 +196,7 @@ def main(): # (except 'hue' which is 0..360) out.write(f'#{idx};2;{random.randrange(101)};{random.randrange(101)};{random.randrange(101)}') - for row in range(six_height // 6): # Each sixel is 6 pixels + for row in range(six_rows): band_count = random.randrange(32) for band in range(band_count): # Choose a random color @@ -211,7 +212,7 @@ def main(): if band + 1 < band_count: # Move cursor to beginning of current row out.write('$') - elif row + 1 < six_height // 6: + elif row + 1 < six_rows: # Newline out.write('-') -- cgit v1.3 From 8ba455f70e0acfaa4ee61fb71a415e796e27dfce Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 11:37:47 +0100 Subject: generate-alt-random: DECGRI: random repeat lengths --- scripts/generate-alt-random-writes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 93a542a7..0923501b 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -206,7 +206,11 @@ def main(): for col in range(six_width): out.write(f'{random.choice(sixels)}') else: - out.write(f'!{six_width}{random.choice(sixels)}') + pix_left = six_width + while pix_left > 0: + pix_count = random.randrange(pix_left + 1) + out.write(f'!{pix_count}{random.choice(sixels)}') + pix_left -= pix_count # Next line if band + 1 < band_count: -- cgit v1.3 From f3bc5a95b553f41de794db7d3351b79ffcd64efd Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 12:01:18 +0100 Subject: generate-alt-random: DECGRI: don’t emit zero-length repeat sequences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/generate-alt-random-writes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 0923501b..54a34c01 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -208,9 +208,9 @@ def main(): else: pix_left = six_width while pix_left > 0: - pix_count = random.randrange(pix_left + 1) - out.write(f'!{pix_count}{random.choice(sixels)}') - pix_left -= pix_count + repeat_count = random.randrange(1, pix_left + 1) + out.write(f'!{repeat_count}{random.choice(sixels)}') + pix_left -= repeat_count # Next line if band + 1 < band_count: -- cgit v1.3 From a8186351d16f6daba770ddfb0a850fd0f4d11adf Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 9 Mar 2021 12:02:31 +0100 Subject: generate-alt-random: sixel: emit at least 4 color bands This fixes an issue where there was a relatively high chance of not emitting any color bands at all, causing the final image size to be too small. --- scripts/generate-alt-random-writes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index 54a34c01..2a3b23a5 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -197,7 +197,7 @@ def main(): out.write(f'#{idx};2;{random.randrange(101)};{random.randrange(101)};{random.randrange(101)}') for row in range(six_rows): - band_count = random.randrange(32) + band_count = random.randrange(4, 33) for band in range(band_count): # Choose a random color out.write(f'#{random.randrange(256)}') -- cgit v1.3