[pk_blackorwhitefromhex]

Description

Link: [pk_blackorwhitefromhex]
Author: Pier Kuipers
Category: String
Version: 8.5.x
License: Public Domain
Posted: Feb. 06, 2012
Updated: Feb. 06, 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]

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;

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net