ColorTools[Palette] - Maple Programming Help

Home : Support : Online Help : Graphics : Packages : ColorTools : Palette Object Commands : ColorTools/Palette/KnownColor

ColorTools[Palette]

 KnownColor
 check if a string is a valid color name in a palette

 Calling Sequence KnownColor(P,color)

Description

 • The KnownColor command returns true if color is the name of a color in the palette P.  It is useful for avoiding the errors thrown by the Lookup command for colors not in a palette.

Examples

 > $P≔\mathrm{ColorTools}:-\mathrm{GetPalette}\left("CSS"\right)$
 ${P}{≔}⟨{Palette CSS:}{}\colorbox[rgb]{0,0,0}{{Black}}{}\colorbox[rgb]{1,0,0}{{Red}}{}\colorbox[rgb]{0.501960784313725,0,0}{{Maroon}}{}\colorbox[rgb]{1,0.650980392156863,0}{Orange}{}\colorbox[rgb]{1,1,0}{Yellow}{}\colorbox[rgb]{0.501960784313725,0.501960784313725,0}{Olive}{}\colorbox[rgb]{0,1,0}{Lime}{}\colorbox[rgb]{0,0.501960784313725,0}{{Green}}{}\colorbox[rgb]{0,1,1}{Aqua}{}\colorbox[rgb]{0,0.501960784313725,0.501960784313725}{{Teal}}{}\colorbox[rgb]{0,0,1}{{Blue}}{}\colorbox[rgb]{0,0,0.501960784313725}{{Navy}}{}\colorbox[rgb]{1,0,1}{Fuchsia}{}\colorbox[rgb]{0.501960784313725,0,0.501960784313725}{{Purple}}{}\colorbox[rgb]{0.501960784313725,0.501960784313725,0.501960784313725}{Gray}{}\colorbox[rgb]{0.749019607843137,0.749019607843137,0.749019607843137}{Silver}{}White⟩$ (1)
 > $\mathrm{KnownColor}\left(P,"Grey"\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{KnownColor}\left(P,"Gray"\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{KnownColor}\left(P,"Griy"\right)$
 ${\mathrm{false}}$ (4)

An error will be thrown if a color is not in a palette

 > $\mathrm{Lookup}\left(P,"Griy"\right)$

Compatibility

 • The ColorTools[Palette][KnownColor] command was introduced in Maple 16.