in reply to Re^3: visualizing data in a table
in thread visualizing data in a table

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.

Replies are listed 'Best First'.
Re^5: visualizing data in a table
by BrowserUk (Patriarch) on Mar 31, 2010 at 17:53 UTC

    The idea behind the code started from here.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.