Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: build a distribution

by sflitman (Hermit)
on Aug 07, 2010 at 22:31 UTC ( [id://853598]=note: print w/replies, xml ) Need Help??


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

Very elegant! I ran the code on WinXP ActiveState perl and initially got a black image, but I called rgb2n on $clr and then it worked.

SSF

Replies are listed 'Best First'.
Re^3: build a distribution
by BrowserUk (Patriarch) on Aug 07, 2010 at 23:20 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://853598]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-23 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found