ReverseLookup - Maple Help

ColorTools[Palette]

 ReverseLookup
 look up a color in a Palette object by name or index

 Calling Sequence ReverseLookup(P,color) ReverseLookup(P,color,fast)

Parameters

 P - Palette object created with ColorTools:-Palette color - a color in any format understood by ColorTools fast - (optional) keyword option

Description

 • The ReverseLookup command finds if a color is part of palette P and if so, returns its positive integer index in P.
 • If color is not a member of P and error will occur.
 • If fast is specified, the colors generated when P is expanded automatically will not be checked during the reverse lookup.

Examples

 > $P≔\mathrm{ColorTools}:-\mathrm{GetPalette}\left("spring"\right)$
 ${P}{≔}⟨{Palette Spring:}{}\colorbox[rgb]{0,0.454901960784314,0.8}{{Blue}}{}\colorbox[rgb]{0.8,0,0.454901960784314}{{Rose}}{}\colorbox[rgb]{0.454901960784314,0.8,0}{YellowGreen}{}\colorbox[rgb]{0,0.8,0.745098039215686}{BlueGreen}{}\colorbox[rgb]{0.345098039215686,0,0.8}{{Violet}}{}\colorbox[rgb]{0.294117647058824,0.494117647058824,0.650980392156863}{Cobalt}{}\colorbox[rgb]{0.756862745098039,0.8,0}{Yellow}{}\colorbox[rgb]{0.8,0,0.305882352941176}{{PurpleRed}}{}\colorbox[rgb]{0,0.254901960784314,0.8}{{GreenBlue}}{}\colorbox[rgb]{0.294117647058824,0.650980392156863,0.450980392156863}{PaleGreen}{}\colorbox[rgb]{0.8,0.494117647058824,0}{Orange}{}\colorbox[rgb]{0.745098039215686,0,0.8}{{Purple}}{}\colorbox[rgb]{0,0.8,0.2}{Green}{}\colorbox[rgb]{0,0.654901960784314,0.8}{SeaBlue}{}\colorbox[rgb]{0.607843137254902,0.650980392156863,0.294117647058824}{PaleYellow}{}\colorbox[rgb]{0.294117647058824,0.650980392156863,0.650980392156863}{PaleBlueGreen}⟩$ (1)
 > $\mathrm{ReverseLookup}\left(P,P\left[1\right]\right)$
 ${"Blue"}$ (2)

Using the fast option with ReverseLookup will not check for colors generated by automatic palette expansion.

 > $\mathrm{Lookup}\left(P,\mathrm{numcolors}\left(P\right)+1\right)$
 ${⟨}\colorbox[rgb]{1,0.517647058823529,0.588235294117647}{RGB : 1 0.516 0.589}{⟩}$ (3)
 > $\mathrm{ReverseLookup}\left(P,\mathrm{Lookup}\left(P,\mathrm{numcolors}\left(P\right)+1\right),\mathrm{fast}\right)$

Compatibility

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