Hi Mighty Monks,
A few months ago, I had to deal with GD. Most GD functions expect the colours to be given as lists of three figures (amounts of red, green and blue, in that order, as I'm sure you had already guessed). I for one preferred to store my colours as numbers in a hash, using the handy 0xnnnnnn notation. I thus needed a function that would take an integer as argument and return the three elements: a good opportunity for a bit of golfing (and obfuscation if you care to...).
The function assumes the arguments is a valid hexa triplet, i.e. an integer between 0 and 0xFFFFFF.
My entry (43 chars only counting within the braces):
sub hexa_triplet { map eval"0x$_",sprintf('%06x',pop)=~/(..)/g }
--bwana147
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (GOLF) splitting an hexadecimal colour triplet
by wog (Curate) on Jul 05, 2001 at 20:14 UTC | |
by MeowChow (Vicar) on Jul 05, 2001 at 21:32 UTC | |
by tachyon (Chancellor) on Jul 05, 2001 at 21:24 UTC | |
by btrott (Parson) on Jul 05, 2001 at 21:37 UTC |
Back to
Obfuscated Code