Link | pk_blackorwhitefromhex |
Author | Pier Kuipers |
Category | String |
Version | 8.5.x |
License | Public Domain |
Posted | 06 Feb 2012 |
Updated | 06 Feb 2012 |
More by this author... |
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]
pk_blackorwhitefromhex('a70e13'); -> 'white'
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.
// 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;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft