Hi, I was using
Acme::AsciiArt2HtmlTable which makes tables with coloured cells but has some problems such as limited colours and it's a bit slow(I guess because it's in
Acme namespace it's not really supposed to be used for serious stuff).
anyway got your colourramp1785 and modified it a bit to work with almut's GD snippet:
my @map=(
sub{( 0, 0, $_[0] * 255 )},
sub{( 0, $_[0]*255, 255 )},
sub{( 0, 255, (1-$_[0])*255 )},
sub{( $_[0]*255, 255, 0 )},
sub{( 255, (1-$_[0])*255, 0 )},
sub{( 255, 0, $_[0]*255 )},
sub{( 255, $_[0]*255, 255 )},
);
sub ramp {
my( $v, $vmin, $vmax ) = @_;
## Peg $v to $vmax if it is greater than $vmax
$v = $vmax if $v > $vmax;
## Or peg $v to $vmin if it is less tahn $vmin.
$v = $vmin if $v < $vmin;
## Normalise $v relative to $vmax - $vmin
$v =
( $v - $vmin ) /
( $vmax - $vmin ) ;
## Scale it to the range 0 .. 1784
$v *= 1785;
my @a =
map { int }
$map[$v/255]->( ($v % 255) / 256 );
#print join(',',@a)."\n";
return
($a[2]<<8 ) |
($a[1]<<4 ) |
($a[0] ) ;
};
I'm using it in a loop like so:
$img->setPixel($x, $y, $some_val_from_a_table , 1,16 )) ;
it works ok but sometime produces colours which are too near to each other to be distinguished easily.
Browser_Uk , how di dyou write your colour ramp ? I read about some
colour ramps <-- here, but not sure if they fit the common usage.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.