Here’s another idea, and I believe it’s a brilliant idea.
Why would something like this be useful. For one thing, it’s very maintainable. Assuming you set up the variable, you can do a construct like this.
So, this means you can look at corresponding initials. You don’t even need to worry about the number of arguments or setting ==0 and so. You can add argument initials, then add elif $variable and add in your argument there.
Example
#@cli rep_satellite: color_mapping,_gray_mode={ 0=luminosity | 1=luminosity_alternative | 2=lightness | 3=minimum_channel | 4=maximum_channel | 5=average },-1>=_midpoint_shift>=1,_sigmoid_level>=0,_normalize,color_position_a,....color_position_b,{ [palette] | hex_color_a },....,hex_color_z,....
#@cli : Apply Satellite mapping onto images.
#@cli : Default values: '_gray_mode=0'
rep_satellite:
skip ${2=0},${3=0},${4=0},${5=0}
# Code Block
custom,pal,palette=-1
use_custom_palette,utilize_sig_adj,normalize_image=0,{[$3!=0||$4!=0,$5]}
list_of_palettes_with_single_initials=avn,bd,ft,jsl,ir2,ir2f,ir2h,ir2w,ir3,ir3b,rb,rbtop
number_of_pal_args={narg($list_of_palettes_with_single_initials)}
if isnum($1)
pal_choice={$1>=0?int($1)%$number_of_pal_args:-1}
else
$list_of_palettes_with_single_initials={expr('x',narg($list_of_palettes_with_single_initials))}
pal_choice=$$1
if !narg($pal_choice) error inv_inp_\$1 fi
fi
if $pal_choice==-1
use_custom_palette=1
else
$list_of_palettes_with_single_initials={v=vector$number_of_pal_args(0);v[$pal_choice]=1;v;}
fi
if isnum($2)
c2g_mode={int($2)%6}
else
m_luminosity,m_luminosity_alt,m_lightness,m_min,m_minimum,m_max,m_maximum,m_avg,m_average=0,1,2,{expr('x>>1',6)+3}
c2g_mode=${m_$2}
if !narg($c2g_mode) error inv_inp_\$2 fi
fi
append_back=0
foreach {
# Code Block
100%,100%,100%,1,"begin(
const c2g_mode=$c2g_mode;
c2g_mode==0?graymode(color)=color[0]*0.22248840+color[1]*0.71690369+color[2]*0.06060791:
c2g_mode==1?graymode(color)=color[0]*0.2990+color[1]*0.5870+color[2]*0.1140:
c2g_mode==2?graymode(color)=(max(color)+min(color))/2:
c2g_mode==3?graymode(color)=min(color):
c2g_mode==4?graymode(color)=max(color):
graymode(color)=avg(color);
);
graymode(I#0);"
# Code Block
}
if $use_custom_palette
# Code Block
else
if $avn
rep_satellite_create_reference_palette 48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,250
# Code Block
elif $bd
rep_satellite_create_reference_palette 59,68,97,175,188,199,209,215,221,226
# Code Block
elif $ft
rep_satellite_create_reference_palette 44,152,184,204,216,224,237,253
# Code Block
elif $jsl
rep_satellite_create_reference_palette 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,132,144,156,168,180,184,188,192,196,200,202,215,226,246
# Code Block
elif $ir2
rep_satellite_create_reference_palette 2,26,51,62,68,69,81,111,131,171
# Code Block
elif $ir2f
rep_satellite_create_reference_palette 151
# Code Block
elif $ir2h
rep_satellite_create_reference_palette 13,126
# Code Block
elif $ir2w
rep_satellite_create_reference_palette 42,191
# Code Block
elif $rb
rep_satellite_create_reference_palette 4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136,140,144,148,152,156,160,164,168,172,176,180,184,188,192,196,200,204,208,212,216,220,224,228,232,236
# Code Block
elif $rbtop
rep_satellite_create_reference_palette 61,91,101,145,155,171,191,201,211,221,246
# Code Block
elif $ir3
rep_satellite_create_reference_palette 130,165,183,198,206,214,222,230
# Code Block
elif $ir3b
rep_satellite_create_reference_palette 110,142,172,192,219
# Code Block
else error pal_id_no_info
fi
permute. yzcx
fi
contain_alpha=0
# Code Block
If you study the code, you’ll note that $1 can be a number or any of the following: avn,bd,ft,jsl,ir2,ir2f,ir2h,ir2w,ir3,ir3b,rb,rbtop. $2 case is a different version, but still showcases the benefit of said technique as $2 can be typed as min,max,lightness and it’ll work. This is easier to maintain, and the end user reap the benefits of not having to use numbers as argument.
On second thought, there might not be too much changes in context of line of codes. Maybe not that much benefit, but I’ll leave it to others to decide if this is worth it. There’s only benefit in context of complexity reduction of coding structure, but equally just as maintainable, but more so than the usual approach of having only $n as numbers.