From b334c49beb2fad9e4f5e6d6766250d227de3de1e Mon Sep 17 00:00:00 2001 From: James Holderness Date: Sun, 17 Oct 2021 11:42:22 +0100 Subject: [PATCH 1/2] Test the effect of DECGRA on Background Select This test demonstrates how the DECGRA dimensions determine the extent of the area that is filled by the Background Select functionality. It also shows how both the Background Select parameter and the DECGRA extent have an influence on which pixels are rendered as transparent. --- j4james/background_select.sh | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 j4james/background_select.sh diff --git a/j4james/background_select.sh b/j4james/background_select.sh new file mode 100644 index 0000000..90bfc12 --- /dev/null +++ b/j4james/background_select.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +# Test the effect of DECGRA on the Background Select functionality. + +# When the Background Select parameter is set to 0 or 2, the background of the +# image is filled with color map entry 0, before any sixel data is output. The +# extent of the the filled area is determined by the dimensions defined in the +# DECGRA raster attributes. If not specified, the maximum extent is used. + +CSI=$'\e[' # Control Sequence Introducer +DCS=$'\eP' # Device Control String +ST=$'\e\\' # String Terminator + + +echo -n ${CSI}'!p' +echo -n ${CSI}'H' +echo -n ${CSI}'J' +echo -n ${CSI}'?7h' +yes E | tr -d '\n' | head -c 1920 + +set_cursor_pos() { + echo -n ${CSI}${1}';'${2}'H' +} + +# This should fill area extending to the bottom right of the screen. +#-The DECGRA is ignored when not followed by a command or sixel data. +set_cursor_pos 21 73 +echo -n ${DCS}'q"1;1;10;10'${ST} + +# This should fill an area of 80x80px. +# The color introducer is enough to activate the DECGRA dimensions. +set_cursor_pos 1 1 +echo -n ${DCS}'q"1;1;80;80#'${ST} + +# This should fill an area 80px wide extending to the bottom of the screen. +# The zero DECGRA height parameter defaults to the maximum extent. +set_cursor_pos 21 1 +echo -n ${DCS}'q"1;1;80;0#'${ST} + +# This should fill an area 80px high extending to the width of the screen. +# The zero DECGRA width parameter defaults to the maximum extent. +set_cursor_pos 1 73 +echo -n ${DCS}'q"1;1;0;80#'${ST} + +# This should fill an area 80px wide extending to the bottom of the screen. +# The second DECGRA overrides the first, and the missing height parameter +# defaults to the maximum extent. +set_cursor_pos 21 37 +echo -n ${DCS}'q"1;1;10;10"1;1;80?'${ST} + +# This should fill an area 80px high extending to the width of the screen. +# The second DECGRA overrides the first, and the missing width parameter +# defaults to the maximum extent. +set_cursor_pos 11 73 +echo -n ${DCS}'q"1;1;10;10"1;1;;80?'${ST} + +# This should fill an area of 80x80px. +# The second DECGRA overwrites the first, but the last one is ignored, +# since it's not followed by anything. +set_cursor_pos 1 37 +echo -n ${DCS}'q"1;1;120;40"1;1;80;80"1;1;40;120'${ST} + +# This should fill an area of 80x80px. +# The ? sixel is enough to activate the last DECGRA in this case. +set_cursor_pos 11 1 +echo -n ${DCS}'q"1;1;120;40"1;1;40;120"1;1;80;80?'${ST} + +# This should fill an area of 180x180px, containing a 60x60px blue square. +# The first DECGRA applies to the DECNL, moving down by 90px (AR 15:1). +# The second applies to the sixels, producing a height of 60px (AR 10:1). +set_cursor_pos 4 18 +echo -n ${DCS}';0q"15;1-"10;1;180;180?-#1!60?!60~'${ST} + +# This should fill an area of 180x180px in blue. +# When the background select is 1, the DECGRA dimensions have no effect. +set_cursor_pos 4 46 +echo -n ${DCS}';1q"15;1;240;240-#1!180~-!180~'${ST} + +# This should fill an area of 60x60px in black. +# The first 30px are skipped with a DECGNL, ? triggers a background fill of +# 60x30, and another 60x30 is drawn in black. The final 60x30 is transparent, +# despite the background select of 2, because it's beyond the image height. +set_cursor_pos 10 52 +echo -n ${DCS}';2q"5;1;60;30-?-#0!60~-!60?'${ST} + +set_cursor_pos 7 1 From 3fb3663652735edce382e50237411277c67439fe Mon Sep 17 00:00:00 2001 From: James Holderness Date: Tue, 19 Oct 2021 15:31:03 +0100 Subject: [PATCH 2/2] Fix interpretation of default DECGRA attributes When the dimensions in a DECGRA command are not specified, it uses the values from any preceding DECGRA (if there is one), and only falls back to using the maximum extent as a last resort. --- j4james/background_select.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/j4james/background_select.sh b/j4james/background_select.sh index 90bfc12..9a25acd 100644 --- a/j4james/background_select.sh +++ b/j4james/background_select.sh @@ -5,7 +5,8 @@ # When the Background Select parameter is set to 0 or 2, the background of the # image is filled with color map entry 0, before any sixel data is output. The # extent of the the filled area is determined by the dimensions defined in the -# DECGRA raster attributes. If not specified, the maximum extent is used. +# DECGRA raster attributes. If not specified, the preceding DECGRA's attributes +# are used (if there were multiple DECGRAs), or otherwise the maximum extent. CSI=$'\e[' # Control Sequence Introducer DCS=$'\eP' # Device Control String @@ -42,17 +43,17 @@ echo -n ${DCS}'q"1;1;80;0#'${ST} set_cursor_pos 1 73 echo -n ${DCS}'q"1;1;0;80#'${ST} -# This should fill an area 80px wide extending to the bottom of the screen. +# This should fill an area of 80x80px. # The second DECGRA overrides the first, and the missing height parameter -# defaults to the maximum extent. -set_cursor_pos 21 37 -echo -n ${DCS}'q"1;1;10;10"1;1;80?'${ST} +# falls back to the value from the first DECGRA. +set_cursor_pos 11 73 +echo -n ${DCS}'q"1;1;10;80"1;1;80?'${ST} -# This should fill an area 80px high extending to the width of the screen. +# This should fill an area of 80x80px. # The second DECGRA overrides the first, and the missing width parameter -# defaults to the maximum extent. -set_cursor_pos 11 73 -echo -n ${DCS}'q"1;1;10;10"1;1;;80?'${ST} +# falls back to the value from the first DECGRA. +set_cursor_pos 21 37 +echo -n ${DCS}'q"1;1;80;10"1;1;;80?'${ST} # This should fill an area of 80x80px. # The second DECGRA overwrites the first, but the last one is ignored,