As a proponent of open source software, I present a straightforward method to reverse engineer Mathematica colormaps. RGB values for a named colormap can be extracted with the command

Apply[List, Map[ColorData["M10DefaultDensityGradient"], Range[0, 1, .01]], {1}]

where Apply and Map have be written out explicitly to avoid the language shortcuts often seen but not simple to decipher. This can be done for any number of sampling points, but the hundred plus here is sufficient to describe the individual color curves.

While one can directly interpolate the sampled color data to produce a colormap function, this is a rather clumsy approach that unnecessarily clogs a code library with numeric data. A more elegant approach appears upon visual inspection of the curves. Those for the default density map are

Surprisingly, many of the Mathematica colormaps turn out to be simple piecewise functions like this one, so that decent mathematical approximations are not difficult to generate. By inspection one can pick an interpolating function for successive pieces of the curve and apply the Fit command over appropriate intervals. Many of the curves are well fit with simple linear expressions, allowing the colormap functions to be described concisely.

This notebook contains sampled data, individual color plots and piecewise approximations to the data for the Mathematica colormaps in the library MathCell. It can be used to refine the existing maps or generate new ones. Keep in mind that variable definitions are not unique in this file and the appropriate cell generating the sampled data must be evaluated before reevaluating fitting functions.

In MathCell the coefficients of fitting functions are rounded to three decimals places. This saves space without seriously impacting the visual appearance of the maps. The resulting interpolating functions can be retrieved from the library source code:

The entry for each color is an array of pieces with a function valid over the indicated domain. Keep in mind that Mathematica uses one-based indexing when reading these domains from the notebook.

The following graphic displays the piecewise functions for each colormap, allowing inspection of the smoothness of individual components:

While there are some minor glitches between pieces of some of the colormaps, this does not affect the visual appearances of the maps. The relative simplicity of the interpolated functions certainly outweighs the extra data one would have from brute interpolation.

The Mathematica colormaps available in MathCell are visualized here:

Code on!

Uploaded 2020.05.02