(none) imager-devel
/ help / lists / applications / search /


From: Arnar Mar Hrafnkelsson (
Date: Mon 21 May 2001 - 17:48:42 UTC

  • Next message: 01905@xyz.molar.is: "Re: Imager-0.38pre9 Released."

    The following are our choices:

    # Old interfaces:

    $color = Imager::Color->new($red, $green, $blue, $alpha);
    $color = Imager::Color->new("#C0C0FF");
    $color = Imager::Color->new("#C0C0FFAA"); # This works today

    # New interfaces:

    1. $color = Imager::Color->new(red=>100, green=>0, blue=>255, alpha=>128);
    2. $color = Imager::Color->new(rgb=>[100, 0, 255], alpha=>128);
    3. $color = Imager::Color->new(htmlspec=>'#C0C0FF', alpha=>$a);
    4. $color = Imager::Color->new(Xspec=>'red', alpha=>$a);
    5. $color = Imager::Color->new(channels=>\@clist);

    The second set looks nicer but they are a bit verbatim for some purposes.
    It looks like it would be possible to implement all of those

    The question is if we really want to implement all of those. At first I
    didn't see any reason with the rgb=>[$r, $g, $b] constructor until I
    realized that it would make sense to have it so we could also have
    hsv=>[$h, $s, $v], and a method for cmyk, and other nasty color spaces.
    Another thing that should be taken into consideration is the multichannel
    case (more than 4 channels). Then the first interface makes the most
    sense but It's questionable if that should be used.

    What I propose is That we allow the old interface for now but document
    mention that it is deprecated unless you do something like

    use Imager qw(:handy); # since then you get the NC() hacks too.

    But implement the new ones.

    The first one makes sense since you could specify gray=> and it would
    work consistently for grayscale or color images. (This requires that we
    implement image classes, or at least store the alpha channel some how
    special in the color entry).

    The second one would be our way of entering various colorspaces (and add
    methods for extracting those spaces would via member functions like
    ($h, $s, $v) = $color->hsv() ??).

    3 and 4 are just convenience things to avoid formatting changes.. I'm not
    so sure if it is a good idea to lookup in /usr/X11R6/lib/X11/rgb.txt.

    5. To be able to specify a large number of channels. (when we re-add
    multispectral support).

    -- Arnar.