Skip to content

Commit be3b588

Browse files
author
Chad Juliano
committed
Update HSL names.
1 parent 2c20a1e commit be3b588

File tree

4 files changed

+70
-68
lines changed

4 files changed

+70
-68
lines changed

src/biw-panel-credits.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function fn_color_map_hsl_hue()
114114
{
115115
local -ir _hsl_sat=4
116116
local -ir _hsl_light=5
117+
local -ir _color_repeat=2
117118

118119
local -i _hsl_hue
119120
local -i _sgr_code
@@ -124,12 +125,12 @@ function fn_color_map_hsl_hue()
124125
cred_color_map=()
125126
cred_color_map[_map_idx++]=0
126127

127-
for((_hsl_hue = HSL_HUE_GREEN; _hsl_hue <= HSL_HUE_BLUE; _hsl_hue++))
128+
for((_hsl_hue = HSL216_HUE_GREEN; _hsl_hue <= HSL216_HUE_BLUE; _hsl_hue++))
128129
do
129-
fn_hsl_get $_hsl_hue $_hsl_sat $_hsl_light
130+
fn_hsl216_get $_hsl_hue $_hsl_sat $_hsl_light
130131
_sgr_code=$?
131132

132-
for((_hsl_sat_length = 0; _hsl_sat_length <= 2; _hsl_sat_length++))
133+
for((_hsl_sat_length = 0; _hsl_sat_length <= $_color_repeat; _hsl_sat_length++))
133134
do
134135
cred_color_map[_map_idx++]=$_sgr_code
135136
done
@@ -157,7 +158,7 @@ function fn_color_map_hsl_saturation()
157158
# we go from partially saturated green (sat=3) because (sat=5) is too deep.
158159
for((_hsl_sat = _max_hsl_hue; _hsl_sat >= _min_hsl_hue; _hsl_sat--))
159160
do
160-
fn_hsl_get $_hsl_hue $_hsl_sat $_hsl_light
161+
fn_hsl216_get $_hsl_hue $_hsl_sat $_hsl_light
161162
_sgr_code=$?
162163

163164
for((_hsl_sat_length = 0; _hsl_sat_length <= 4; _hsl_sat_length++))

src/biw-term-hsl.sh

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@
66
# reserved. See LICENSE.
77
#
88
# File: biw-term-hsi.sh
9-
# Description: Compute HSL (Hue/Saturation/Light) color space.
9+
# Description: Compute HSL (Hue/Saturation/Light) color space in 216
10+
# color SGR mode.
1011
##
1112

1213
# colorspace params
13-
declare -ir HSL_HUE_SIZE=36
14-
declare -ir HSL_HUE_SECTORS=6
15-
declare -ir HSL_SAT_SIZE=6
16-
declare -ir HSL_LIGHT_SIZE=6
14+
declare -ir HSL216_HUE_SIZE=36
15+
declare -ir HSL216_HUE_SECTORS=6
16+
declare -ir HSL216_SAT_SIZE=6
17+
declare -ir HSL216_LIGHT_SIZE=6
1718

1819
# Hue colors
19-
declare -ir HSL_HUE_RED=$((0*HSL_HUE_SECTORS))
20-
declare -ir HSL_HUE_YELLOW=$((1*HSL_HUE_SECTORS))
21-
declare -ir HSL_HUE_GREEN=$((2*HSL_HUE_SECTORS))
22-
declare -ir HSL_HUE_CYAN=$((3*HSL_HUE_SECTORS))
23-
declare -ir HSL_HUE_BLUE=$((4*HSL_HUE_SECTORS))
24-
declare -ir HSL_HUE_MAGENTA=$((5*HSL_HUE_SECTORS))
20+
declare -ir HSL216_HUE_RED=$((0*HSL216_HUE_SECTORS))
21+
declare -ir HSL216_HUE_YELLOW=$((1*HSL216_HUE_SECTORS))
22+
declare -ir HSL216_HUE_GREEN=$((2*HSL216_HUE_SECTORS))
23+
declare -ir HSL216_HUE_CYAN=$((3*HSL216_HUE_SECTORS))
24+
declare -ir HSL216_HUE_BLUE=$((4*HSL216_HUE_SECTORS))
25+
declare -ir HSL216_HUE_MAGENTA=$((5*HSL216_HUE_SECTORS))
2526

2627
# lookup table for HSV-RGB transformations
27-
declare -a HSL_TABLE
28-
declare -ir HSL_TABLE_SIZE=$((HSL_HUE_SIZE * HSL_SAT_SIZE * HSL_LIGHT_SIZE))
28+
declare -a HSL216_TABLE_DATA
29+
declare -ir HSL216_TABLE_SIZE=$((HSL216_HUE_SIZE * HSL216_SAT_SIZE * HSL216_LIGHT_SIZE))
2930

3031
# Interpolate y coordinates
3132
# Parameters)
@@ -57,11 +58,11 @@ function fn_hsl_interp_y()
5758

5859
# Calculate HSL color space (36x6x6) for the lookup table.
5960
# Normalization for S<0 or H>=36 # are handled after the table calculation
60-
# in fn_hsl_set.
61+
# in fn_hsl216_set.
6162
# This algorithm makes use of the fn_hsl_interp_y routine to simplify code at the
6263
# cost of minor additional computations. It is adapted for integer
6364
# calculations for a small set of colors.
64-
function fn_hsl_calc()
65+
function fn_hsl216_calc()
6566
{
6667
local -i _hue=$1
6768
local -i _sat=$2
@@ -103,25 +104,25 @@ function fn_hsl_calc()
103104
}
104105

105106
# Compute HSV table of 6*6*36=1296 values.
106-
function fn_hsl_init()
107+
function fn_hsl216_init()
107108
{
108-
HSL_TABLE[HSL_TABLE_SIZE - 1]=0
109+
HSL216_TABLE_DATA[HSL216_TABLE_SIZE - 1]=0
109110

110111
local -i _hue _sat _light
111112
local -i _sgr_code
112113
local -i _lut_idx
113114

114-
for((_light = 0; _light < HSL_LIGHT_SIZE; _light++))
115+
for((_light = 0; _light < HSL216_LIGHT_SIZE; _light++))
115116
do
116-
for((_sat = 0; _sat < HSL_SAT_SIZE; _sat++))
117+
for((_sat = 0; _sat < HSL216_SAT_SIZE; _sat++))
117118
do
118-
for((_hue = 0; _hue < HSL_HUE_SIZE; _hue++))
119+
for((_hue = 0; _hue < HSL216_HUE_SIZE; _hue++))
119120
do
120-
fn_hsl_calc $_hue $_sat $_light
121+
fn_hsl216_calc $_hue $_sat $_light
121122
_sgr_code=$?
122123

123-
_lut_idx=$((_light*HSL_SAT_SIZE*HSL_HUE_SIZE + _sat*HSL_HUE_SIZE + _hue))
124-
HSL_TABLE[_lut_idx]=$_sgr_code
124+
_lut_idx=$((_light*HSL216_SAT_SIZE*HSL216_HUE_SIZE + _sat*HSL216_HUE_SIZE + _hue))
125+
HSL216_TABLE_DATA[_lut_idx]=$_sgr_code
125126
done
126127
done
127128
done
@@ -134,13 +135,13 @@ function fn_hsl_init()
134135
# 3) Saturation [-5..5]: Indicates amount of color. Negative values will
135136
# invert color.
136137
# 4) Light [0..5]: Indicates luminosity.
137-
function fn_hsl_get()
138+
function fn_hsl216_get()
138139
{
139140
local -i _hue=$1
140141
local -i _sat=$2
141142
local -i _light=$3
142143

143-
if((_light >= HSL_LIGHT_SIZE))
144+
if((_light >= HSL216_LIGHT_SIZE))
144145
then
145146
echo "Error: L value must be the range [0..5]: ${_light}"
146147
exit 1
@@ -150,27 +151,27 @@ function fn_hsl_get()
150151
if((_sat < 0))
151152
then
152153
_sat=$((_sat * -1))
153-
_hue=$((_hue + HSL_HUE_SIZE/2 - 1))
154+
_hue=$((_hue + HSL216_HUE_SIZE/2 - 1))
154155
fi
155156

156157
# handle cyclic hue
157-
if((_hue >= HSL_HUE_SIZE))
158+
if((_hue >= HSL216_HUE_SIZE))
158159
then
159-
_hue=$((_hue % HSL_HUE_SIZE))
160+
_hue=$((_hue % HSL216_HUE_SIZE))
160161
fi
161162

162163
# get value from lookup table
163-
local -i _lut_size=${#HSL_TABLE[*]}
164+
local -i _lut_size=${#HSL216_TABLE_DATA[*]}
164165
local -i _sgr_code
165166

166167
if((_lut_size > 0))
167168
then
168169
# get from table
169-
_lut_idx=$((_light*HSL_SAT_SIZE*HSL_HUE_SIZE + _sat*HSL_HUE_SIZE + _hue))
170-
_sgr_code=${HSL_TABLE[_lut_idx]}
170+
_lut_idx=$((_light*HSL216_SAT_SIZE*HSL216_HUE_SIZE + _sat*HSL216_HUE_SIZE + _hue))
171+
_sgr_code=${HSL216_TABLE_DATA[_lut_idx]}
171172

172173
else
173-
fn_hsl_calc $_hue $_sat $_light
174+
fn_hsl216_calc $_hue $_sat $_light
174175
_sgr_code=$?
175176
fi
176177

@@ -185,15 +186,15 @@ function fn_hsl_get()
185186
# 3) Saturation [-5..5]: Indicates amount of color. Negative values will
186187
# invert color.
187188
# 4) Light [0..5]: Indicates luminosity.
188-
function fn_hsl_set()
189+
function fn_hsl216_set()
189190
{
190191
local -i _mode=$1
191192
local -i _hue=$2
192193
local -i _sat=$3
193194
local -i _light=$4
194195

195196
local -i _sgr_code
196-
fn_hsl_get $_hue $_sat $_light
197+
fn_hsl216_get $_hue $_sat $_light
197198
_sgr_code=$?
198199

199200
fn_sgr_color216_set $_mode $_sgr_code

src/biw-theme.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function fn_theme_set_attr()
224224

225225
if((_sgr_attr_fg))
226226
then
227-
if((_sgr_attr_fg))
227+
if((_sgr_attr_bg))
228228
then
229229
echo "ERROR: _sgr_attr_fg and _sgr_attr_bg can't both be set."
230230
fi

test/hsl-demo.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function fn_print_padding()
1818
local _result
1919

2020
printf -v _result '%*s' $_width
21-
echo -n "${_result// /$_char}"
21+
printf "%s" "${_result// /$_char}"
2222
}
2323

2424
function fn_print_heading()
@@ -38,7 +38,7 @@ function fn_print_heading()
3838
fn_print_padding $_end '-'
3939
}
4040

41-
function fn_hsl_sat_blocks()
41+
function fn_demo_hsl216_sat_blocks()
4242
{
4343
local -ir _margin=4
4444
local -a _sat_list=( $* )
@@ -53,17 +53,17 @@ function fn_hsl_sat_blocks()
5353
echo
5454

5555
local -i _light
56-
for((_light = HSL_LIGHT_SIZE - 1; _light >= 0; _light--))
56+
for((_light = HSL216_LIGHT_SIZE - 1; _light >= 0; _light--))
5757
do
5858
for _sat in ${_sat_list[@]}
5959
do
6060
echo -n "L=${_light}) "
6161

6262
fn_sgr_seq_start
6363

64-
for((_hue = 0; _hue < HSL_HUE_SIZE; _hue++))
64+
for((_hue = 0; _hue < HSL216_HUE_SIZE; _hue++))
6565
do
66-
fn_hsl_set $SGR_ATTR_BG $_hue $_sat $_light || exit 1
66+
fn_hsl216_set $SGR_ATTR_BG $_hue $_sat $_light || exit 1
6767
fn_sgr_print " "
6868
done
6969

@@ -77,14 +77,14 @@ function fn_hsl_sat_blocks()
7777
echo
7878
}
7979

80-
function fn_hsl_sat_demo()
80+
function fn_demo_hsl216_sat()
8181
{
82-
fn_hsl_sat_blocks 0 1
83-
fn_hsl_sat_blocks 2 3
84-
fn_hsl_sat_blocks 4 5
82+
fn_demo_hsl216_sat_blocks 0 1
83+
fn_demo_hsl216_sat_blocks 2 3
84+
fn_demo_hsl216_sat_blocks 4 5
8585
}
8686

87-
function fn_hsl_lum_blocks()
87+
function fn_demo_hsl216_lum_blocks()
8888
{
8989
local -ir _margin=4
9090
local -a _lum_list=( $* )
@@ -99,17 +99,17 @@ function fn_hsl_lum_blocks()
9999
echo
100100

101101
local -i _light
102-
for((_light = HSL_LIGHT_SIZE - 1; _light >= 0; _light--))
102+
for((_light = HSL216_LIGHT_SIZE - 1; _light >= 0; _light--))
103103
do
104104
for _light in ${_lum_list[@]}
105105
do
106106
echo -n "S=${_sat}) "
107107

108108
fn_sgr_seq_start
109109

110-
for((_hue = 0; _hue < HSL_HUE_SIZE; _hue++))
110+
for((_hue = 0; _hue < HSL216_HUE_SIZE; _hue++))
111111
do
112-
fn_hsl_set $SGR_ATTR_BG $_hue $_sat $_light || exit 1
112+
fn_hsl216_set $SGR_ATTR_BG $_hue $_sat $_light || exit 1
113113
fn_sgr_print " "
114114
done
115115

@@ -123,14 +123,14 @@ function fn_hsl_lum_blocks()
123123
echo
124124
}
125125

126-
function fn_hsl_lum_demo()
126+
function fn_demo_hsl216_lum()
127127
{
128-
fn_hsl_lum_blocks 0 1
129-
fn_hsl_lum_blocks 2 3
130-
fn_hsl_lum_blocks 4 5
128+
fn_demo_hsl216_lum_blocks 0 1
129+
fn_demo_hsl216_lum_blocks 2 3
130+
fn_demo_hsl216_lum_blocks 4 5
131131
}
132132

133-
function fn_hsl_comp_blocks()
133+
function fn_demo_hsl216_comp_blocks()
134134
{
135135
local -ir _margin=4
136136
local -a _hue_list=( $* )
@@ -144,13 +144,13 @@ function fn_hsl_comp_blocks()
144144
echo
145145

146146
local -i _light
147-
for((_light = HSL_LIGHT_SIZE - 1; _light >= 0; _light--))
147+
for((_light = HSL216_LIGHT_SIZE - 1; _light >= 0; _light--))
148148
do
149149
for _hue in ${_hue_list[@]}
150150
do
151-
for((_sat = -1*(HSL_SAT_SIZE - 1); _sat < HSL_SAT_SIZE; _sat++))
151+
for((_sat = -1*(HSL216_SAT_SIZE - 1); _sat < HSL216_SAT_SIZE; _sat++))
152152
do
153-
fn_hsl_set $SGR_ATTR_BG $_hue $_sat $_light || exit 1
153+
fn_hsl216_set $SGR_ATTR_BG $_hue $_sat $_light || exit 1
154154
echo -n " "
155155
done
156156
fn_sgr_set $SGR_ATTR_DEFAULT
@@ -161,19 +161,19 @@ function fn_hsl_comp_blocks()
161161
echo
162162
}
163163

164-
function fn_hsl_comp_demo()
164+
function fn_demo_hsl216_comp()
165165
{
166-
fn_hsl_comp_blocks 0 3 6
167-
fn_hsl_comp_blocks 9 12 15
166+
fn_demo_hsl216_comp_blocks 0 3 6
167+
fn_demo_hsl216_comp_blocks 9 12 15
168168
}
169169

170-
echo "Computing HSL Table..."
171-
fn_hsl_init
170+
echo "Computing HSL216 Table..."
171+
fn_hsl216_init
172172

173173
# display 6 rainbows of variable saturation
174-
fn_hsl_sat_demo
174+
fn_demo_hsl216_sat
175175

176-
#fn_hsl_lum_demo
176+
#fn_demo_hsl216_lum
177177

178178
# display 6 blocks of color compliments by saturation
179-
fn_hsl_comp_demo
179+
fn_demo_hsl216_comp

0 commit comments

Comments
 (0)