{
    "mode": "perldoc",
    "parameter": "Graphics::Toolkit::Color::Name",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Graphics%3A%3AToolkit%3A%3AColor%3A%3AName/json",
    "generated": "2026-10-04T17:23:19Z",
    "synopsis": "use Graphics::Toolkit::Color::Name qw/:all/;\nmy @names = Graphics::Toolkit::Color::Name::all();\nmy @rgb  = rgbfromname('darkblue');\nmy @hsl  = hslfromname('darkblue');\nGraphics::Toolkit::Color::Value::addrgb('lucky', [0, 100, 50]);",
    "sections": {
        "NAME": {
            "content": "Graphics::Toolkit::Color::Name - access values of color constants\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Graphics::Toolkit::Color::Name qw/:all/;\nmy @names = Graphics::Toolkit::Color::Name::all();\nmy @rgb  = rgbfromname('darkblue');\nmy @hsl  = hslfromname('darkblue');\n\nGraphics::Toolkit::Color::Value::addrgb('lucky', [0, 100, 50]);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "RGB and HSL values of named colors from the X11, HTML(CSS), SVG standard and Pantone report.\nAllows also nearby search, reverse search and storage (not permanent) of additional names. One\ncolor may have multiple names. Own colors can be (none permanently) stored for later reference\nby name. For this a name has to be chosen, that is not already taken. The corresponding color\nmay be defined by an RGB or HSL triplet.\n\nNo symbol is imported by default. The sub symbols: \"rgbfromname\", \"hslfromname\",\n\"namefromrgb\", \"namefromhsl\" may be imported individually or by:\n\nuse Graphics::Toolkit::Color::Name qw/:all/;\n",
            "subsections": []
        },
        "ROUTINES": {
            "content": "rgbfromname\nRed, Green and Blue value of the named color. These values are integer in 0 .. 255.\n\nmy @rgb = Graphics::Toolkit::Color::Name::rgbfromname('darkblue');\n@rgb = Graphics::Toolkit::Color::Name::rgbfromname('darkblue'); # same result\n@rgb = Graphics::Toolkit::Color::Name::rgbfromname('DarkBlue');  # still same\n\nhslfromname\nHue, saturation and lightness of the named color. These are integer between 0 .. 359 (hue) or\n100 (sat. & light.). A hue of 360 and 0 (degree in a cylindrical coordinate system) is\nconsidered to be the same, this modul deals only with the ladder.\n\nmy @hsl = Graphics::Toolkit::Color::Name::hslfromname('darkblue');\n\nnamefromrgb\nReturns name of color with given rgb value triplet. Returns empty string if color is not stored.\nWhen several names define given color, the shortest name will be selected in scalar context. In\narray context all names are given.\n\nsay Graphics::Toolkit::Color::Name::namefromrgb( 15, 10, 121 );  # 'darkblue'\nsay Graphics::Toolkit::Color::Name::namefromrgb([15, 10, 121]);  # works too\n\nnamefromhsl\nReturns name of color with given hsl value triplet. Returns empty string if color is not stored.\nWhen several names define given color, the shortest name will be selected in scalar context. In\narray context all names are given.\n\nsay scalar Graphics::Toolkit::Color::Name::namefromhsl( 0, 100, 50 );  # 'red'\nscalar Graphics::Toolkit::Color::Name::namefromhsl([0, 100, 50]);  # works too\nsay for Graphics::Toolkit::Color::Name::namefromhsl( 0, 100, 50 ); # 'red', 'red1'\n\nnamesinhslrange\nColor names in selected neighbourhood of hsl color space, that look similar. It requires two\narguments. The first one is an array containing three values (hue, saturation and lightness),\nthat define the center of the neighbourhood (searched area).\n\nThe second argument can either be a number or again an array with three values (h,s and l). If\nits just a number, it will be the radius r of a ball, that defines the neighbourhood. From all\ncolors inside that ball, that are equal distanced or nearer to the center than r, one name will\nreturned.\n\nIf the second argument is an array, it has to contain the tolerance (allowed distance) in h, s\nand l direction. Please note the h dimension is circular: the distance from 355 to 0 is 5. The s\nand l dimensions are linear, so that a center value of 90 and a tolerance of 15 will result in a\nsearch of in the range 75 .. 100.\n\nThe results contains only one name per color (the shortest).\n\n# all bright red'ish clors\nmy @names = Graphics::Toolkit::Color::Name::namesinhslrange([0, 90, 50], 5);\n# approximates to :\nmy @names = Graphics::Toolkit::Color::Name::namesinhslrange([0, 90, 50],[ 3, 3, 3]);\n\nall\nA sorted list of all stored color names.\n\ntaken\nA perlish pseudo boolean tells if the color name (first and only, required argument) is already\nin use.\n\naddrgb\nAdding a color to the store under an not taken (not already used) name. Arguments are name, red,\ngreen and blue value (integer < 256, see rgb).\n\nGraphics::Toolkit::Color::Name::addrgb('nightblue',  15, 10, 121 );\nGraphics::Toolkit::Color::Name::addrgb('nightblue', [15, 10, 121]);\n\naddhsl\nAdding a color to the store under an not taken (not already used) name. Arguments are name, hue,\nsaturation and lightness value (see hsl).\n\nGraphics::Toolkit::Color::Name::addrgb('lucky',  0, 100, 50 );\nGraphics::Toolkit::Color::Name::addrgb('lucky', [0, 100, 50]);\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Color::Library\n\nGraphics::ColorNamesLite::All\n\nCOPYRIGHT & LICENSE\nCopyright 2022-23 Herbert Breunung.\n\nThis program is free software; you can redistribute it and/or modify it under same terms as Perl\nitself.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Herbert Breunung, <lichtkind@cpan.org>\n",
            "subsections": []
        }
    },
    "summary": "Graphics::Toolkit::Color::Name - access values of color constants",
    "flags": [],
    "examples": [],
    "see_also": []
}