# How to get properties of ColorDataFunction objects programmatically?

The display forms of ColorDataFunction objects (especially after one clicks on the white + sign on them) indicate that these objects have properties like Name, Class, etc. For example:

ColorData["StarryNightColors"]


ColorData[60]


I'd like to write a function that takes a ColorDataFunction object as an argument. How can this function access the properties of a ColorDataFunction object?

FWIW, expressions like the ones below won't work:

ColorData[60, "ColorFunction", "Properties"]

ColorData[60, "ColorFunction"]["Properties"]

• you can get somewhere inspecting FullForm and then addressing parts, eg ColorData[60, "ColorFunction"][[2]]->"Indexed". Not very satisfactory though. – george2079 May 4 '17 at 15:18
• Related: (76612) – Mr.Wizard May 23 '17 at 9:52

The ColorDataFunction is not atomic,

cdf = ColorData["StarryNightColors"];

AtomQ@cdf
(* False *)


so you have direct access to the arguments. Just replace the head with List and you have the four items listed in the box

List @@ cdf
(* {"StarryNightColors", "Gradients", {0, 1}, Blend["StarryNightColors", #1] &} *)


Strictly speaking, I am only talking about the most important property of ColorDataFunction, because you can use FullForm to get the other properties.

There is some additional information. ColorData[scheme] returns a ColorDataFunction. You can use the returned ColorDataFunction directly.

If you check the definition of ColorDataFunction, you will see only Function f really matters if you don't use illegal parameter as the input of ColorDataFunction/Function f.

In:

ColorData["Gradients"]

ColorData["AlpineColors"]
ColorData["AlpineColors"][x]
ColorData["AlpineColors"][1]

Manipulate[
ColorData["AlpineColors"][x],
{x, 0, 1, 0.01}]


Out: