in reply to Re^3: Perl GD problem
in thread Perl GD problem

Thanks for the advice. I have now made it to true color and am successful in getting all the lines in different color but has brought in another problem. The background has turned black. How can I correct it.

Replies are listed 'Best First'.
Re^5: Perl GD problem
by muntfish (Chaplain) on Aug 17, 2005 at 15:35 UTC

    Why not just draw a big filled rectangle, the size of your image, in white, before you start drawing anything else? Use the filledRectangle method. There may be a more clever way of doing it, but that's how I've solved this king of thing in the past!


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
Re^5: Perl GD problem (Setting background to white)
by radiantmatrix (Parson) on Aug 17, 2005 at 18:59 UTC

    From the GD documentation:

    $index = $image->colorAllocate(red,green,blue)

    This allocates a color with the specified red, green and blue components and returns its index in the color table, if specified. The first color allocated in this way becomes the image's background color. (255,255,255) is white (all pixels on). (0,0,0) is black (all pixels off). (255,0,0) is fully saturated red. (127,127,127) is 50% gray. You can find plenty of examples in /usr/X11/lib/X11/rgb.txt.

    (emphasis is mine)

    So, before your loop do:

    $im->colorAllocate(255,255,255);
    <-radiant.matrix->
    Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law