in reply to Re^2: build a distribution
in thread build a distribution

I called rgb2n on $clr and then it worked.

Hm. That is weird. And I mean re-ally weird!.

$clr is (already) a number in the range 0 .. 2**24: my $clr = 2**24 / $step;, where $step interates from 10 .. 1.

rgb2n() expects input of 3 numbers in the range 0 .. 255, which it then converts to a number in the range 0 .. 2**24. So, besides the crapload of warning that should have been issued, half the lines on the graph would have been drawn in black on black:

c:\test>p1 [0] Perl> sub rgb2n { unpack 'N', pack 'CCCC', 0, @_ } ;; [0] Perl> print rgb2n( 2**24 / $_ ) for reverse 1 .. 10;; Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 10027008 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 13041664 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 0 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 4784128 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 11141120 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 3342336 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 0 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 5570560 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 0 Character in 'C' format wrapped in pack at (eval 6) line 1, <STDIN> li +ne 3. 0

The only possible explanation I can hazard at for this, is that you have a very (very(very)) old version of GD installed that only supports 8-bit color?

Like pre-v2.0. The libgd history doesn't list dates, but from memory, it must at least 5 years ago. I provided a patch for 2.3x, and that was at least 4 years ago.


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.
RIP an inspiration; A true Folk's Guy