Takes an arbitrary hexadecimal background colour value and returns "black" or "white" as the most suitable font colour to be used against this background. Requires [pk_hextorgb]
Parameters
none
Sample Usage
pk_blackorwhitefromhex('a70e13');
-> 'white'
Source Code
Click the "Download" button below to retrieve a copy of this tag,
including the complete documentation and sample usage shown
on this page. Place the downloaded ".inc" file in your
LassoStartup folder, restart Lasso, and you can begin using this
tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Takes an arbitrary hexadecimal background colour value and returns "black" or "white" as the most suitable font colour to be used against this background.
// Requires [pk_hextorgb]
define_tag('blackorwhitefromhex',
-namespace='pk_',
-required='color');
local('output'='black');
local('tmparray'=((pk_hextorgb(#color))->split(' ')));
local('i');
local('value'=integer);
iterate(#tmparray, #i);
#value += (integer(#i));
/iterate;
((#value / 3) < 128) ? #output = 'white';
return(@#output);
/define_tag;