Color gradient explained

In color science, a color gradient (also known as a color ramp or a color progression) specifies a range of position-dependent colors, usually used to fill a region.

In assigning colors to a set of values, a gradient is a continuous colormap, a type of color scheme.In computer graphics, the term swatch[1] has come to mean a palette of active colors.

Definitions

Strict definition

C

f:[rmin,rmax]\subsetR\toC

which is defined by:

r0<...<rm\in[rmin,rmax]

c0,...,cm\inC

f(ri)=ci,i=0,...,m

ri-1<r<ri\in[rmin,rmax]

where:

r\in[rmin,rmax]\subsetR

R

is a set of real numbers

Types

Criteria for classification:

Dimension

Shapes

Axial gradients

An axial color gradient (sometimes also called a linear color gradient) is specified by two points, and a color at each point. The colors along the line through those points are calculated using linear interpolation, then extended perpendicular to that line. In digital imaging systems, colors are typically interpolated in an RGB color space, often using gamma compressed RGB color values, as opposed to linear. CSS and SVG both support linear gradients.[6] [7]

Radial gradients

A radial gradient is specified as a circle that has one color at the edge and another at the center. Colors are calculated by linear interpolation based on distance from the center. This can be used to approximate the diffuse reflection of light from a point source by a sphere. Both CSS and SVG support radial gradients.[8] [9]

Conic gradients

Conic or conical gradients are gradients with color transitions rotated around a center point (rather than radiating from the center). Example conic gradients include pie charts and color wheels.[10] Conic gradients are sometimes called "sweep gradients" (for example in the OpenType specification) or angular gradients.

Other shapes

In vector graphics polygon meshes can be used, e.g., Adobe Illustrator supported gradient meshes.

Color space

Effect of color space

The appearance of a gradient not only varies by the color themselves, but also by the color space the calculation is performed in. The problem usually becomes important for two reasons:

A "linear" blend would match physical light blending and has been the standard in game engines for a long time.[14] On the web, however, it has long been neglected for both color gradients and image scaling.[15] Such a blend still has a subtle difference from one done in a perceptually-uniform color space.[16]

Examples

HSV rainbow

Applications

See also

Notes and References

  1. https://cssgradient.io/swatches/ cssgradient: CSS Gradient Swatches
  2. https://datascience.dsscale.org/wp-content/uploads/2017/10/TheGoodtheBadandtheUgly.pdf The Good, the Bad, and the Ugly: A Theoretical Framework for the Assessment of Continuous Colormaps by Roxana Bujack, Terece L. Turton, Francesca Samsel, Colin Ware
  3. https://blog.datawrapper.de/which-color-scale-to-use-in-data-vis/ which-color-scale-to-use-in-data-vis by Lisa Charlotte Rost
  4. https://www.fabiocrameri.ch/visualisation/#ws-block-features-with-aside-icons-3-cols-mQE9rwEn Fabio Crameri: Scientific colour maps
  5. http://publica.fraunhofer.de/documents/N-337230.html A survey and task-based quality assessment of static 2D colormaps
  6. http://www.w3.org/TR/2012/CR-css3-images-20120417/#linear-gradients Linear Gradients
  7. http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#LinearGradients Linear Gradients
  8. http://www.w3.org/TR/2012/CR-css3-images-20120417/#radial-gradients Radial Gradients
  9. http://www.w3.org/TR/2011/REC-SVG11-20110816/pservers.html#RadialGradients Radial Gradients
  10. https://developer.mozilla.org/en-US/docs/Web/CSS/conic-gradient mozilla docs: CSS conic-gradient
  11. Web site: Computer Color is Broken. https://ghostarchive.org/varchive/youtube/20211221/LKnqECcg6Gw . 2021-12-21 . live. Minute Physics. March 20, 2015. YouTube.
  12. Web site: What every coder should know about gamma . Novak. John. September 21, 2016.
  13. 1903.06490. Zeileis. Achim. colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes. Fisher. Jason C.. Hornik. Kurt. Ihaka. Ross. McWhite. Claire D.. Murrell. Paul. Stauffer. Reto. Wilke. Claus O.. Journal of Statistical Software . 2019. 96 . 10.18637/jss.v096.i01 .
  14. Web site: Chapter 24. The Importance of Being Linear . NVIDIA Developer . en.
  15. Web site: Web color is still broken .
  16. Web site: How software gets color wrong . bottosson.github.io . December 3, 2020 . en.
  17. https://gnuplot.sourceforge.net/docs%204.2/node167.html gnuplot docs 4.2 node167: Color box
  18. Book: Eisenberg, J. David . SVG Essentials . limited . 0-596-00223-8 . 2002 . . 107.