1.0.4 • Published 4 years ago

chromataxy-css v1.0.4

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
4 years ago
  • Over 3 lakh named colors and 2.3 million future-proof utility classes
  • Perceptually uniform1 colours
  • Semantically sound names
  • ii8n2 friendly
  • Accessible by design

Why not other Color Spaces?

  • HSL While this transformation of RGB color space is more intuitive in its representation, the lightness in HSL does not represent perceptual lightness but rather relative brightness.
  • Munsell : While colors were loosely based on perception, they were mostly inconsistent and dependent on the environment. Moreover, quantitative differences could only be defined over a single color attribute3.
  • NCS : Based on the psychophysics of color perception, NCS is better than Munsell as environmental lighting conditions do not impact color choices. However, this system must not be used to model perceived color differences4, which is necessary requirement for a naming system to be accessible.
  • LAB : Though the CIELAB color space represents a broader color gamut with better perceptual accuracy than the Munsell System, the parameters a* and b* makes it harder to arrive at a mental model.

Installation and Usage

Install the package using npm or yarn like:

npm i chromataxy-css // or yarn add chromataxy-css

For development purposes, you can use either the 40 MB coxy.scss file:

/* Your main.scss file, etc. */
@import "~chromataxy-css/coxy"

or the 455 MB ./css/coxy.css file:

/* Your main.css file, etc. */
@import "~chromataxy-css/css/coxy"

Since both of these files are humongous in size, usage of purgecss is highly recommended to remove unused css from your production build to drastically reduce your filesize.

Designing the Nomenclature of Color

To ensure that the naming system is semantically intuitive and accessible, simple adjectives suffixed with their positive, comparative and superlative forms were used to describe the different dimensions of color.

Degrees of Hue Table

All the numbers have units in degrees (not radians). This naming method adds an additional dimension of temperature to distinguish transitional colours between two hues, effectively naming a hue for every 3° rotation. In this table, Base denotes only the root colour without a describing adjective being attached to it. The base color names are generated from the nearest equivalents in Named HTML CSS Colors.

ColourCoolestCoolerCoolBaseWarmWarmerWarmest
CeriseRed14710131619
CinnabarRed21242730333639
FieryOrange41444750535659
CopperOrange61646770737679
LuxorGold81848790939699
OliveGreen101104107110113116119
ForestGreen121124127130133136139
AppleGreen141144147150153156159
SeaGreen161164167170173176179
TealGreen181184187190193196199
PacificBlue201204207210213216219
CuriousBlue221224227230233236239
DodgerBlue241244247250253256259
AzureBlue261264267270273276279
RoyalBlue281284287290293296299
AmethystPurple301304307310313316319
FuchsiaPink321324327330333336339
CerisePink341344347350353356359

This results in a whopping 126 hue variations per combination of chroma and lightness.

Chroma Table

The chroma range (0 - 100) is split into 12 (3 forms of 4 comparative adjectives each) adjectives with 2 extra stops for denoting gray and base colors totalling 14 segments. In this table, Base denotes only the root colour without a describing adjective being attached to it.

ChromaNames
0Gray
9.25Gloomiest
18.5Gloomier
27.75Gloomy
37Dullest
46.25Duller
55.5Dull
66Base
71.65Deep
77.3Deeper
82.95Deepest
88.6Vivid
94.25Vivider
99.9Vividest

Lightness Table

The lightness range (0 - 100) is split into 12 (3 forms of 4 comparative adjectives each) adjectives with 4 extra stops for denoting white, black and base colors totalling 15 segments. In this table, Base denotes only the root colour without a describing adjective being attached to it.

Rationale : Among the 4 chosen adjectives, 2 adjectives (dark and dim) are used to denote the shades of a color while the other 2 (pale and bright) are used to denote the tints. Here, the adjectives describe the lighting of a windowless room (a room without an external light source). Hence, black corresponds to a pitch black room with walls painted with 100% light-absorbing paint and vice versa.

Lightness (in Degrees)Name
0Black
7.25Darkest
14.5Darker
21.75Dark
29Dimmest
36.25Dimmer
43.5Dim
50.75Base
58Pale
65.25Paler
72.5Palest
79.75Bright
87.5Brighter
95.25Brightest
100White

Alpha Table

The alpha range (0 - 100) is split into 9 (3 forms of 3 comparative adjectives each) adjectives with 2 extra stops for denoting transparent and base colors totalling 11 segments. In this table, Base denotes only the root colour without a describing adjective being attached to it.

Rationale : The adjectives chosen (clear, misty and foggy) indicate the appearance of a glass paned window under various weather conditions. Here, a perfectly clear window equates to a transparent color and vice versa.

Alpha (in Percentage)Name
0Transparent
10Clearest
20Clearer
30Clear
40Misty
50Mistier
60Mistiest
70Foggy
80Foggier
90Foggiest
100Base

Thus, each hue consists of 210 variations of Chroma and Lightness. Given that there are 126 hues, About 26,460 named colors can be derived. If we factor in the additional dimension of Transparency, A staggering collection of 2,91,060 named colors can be derived. Of these, removing redundant colors such as shades of pure black, pure white and transparency across all hues, we are left with 2,10,391 unique named colors.

To put that number in perspective, If you cycle through every unique color generated by coxy as your daily desktop wallpaper, it would approximately take you 58 years to eventually run out of unique wallpapers (not including transparency).

Additional Utility Classes

Furthermore, the css utility classes offers graceful degradation irrespective of the hardware support available thus making your css future-proof.

Color PropertyUsage as classDescription
color{color} textSpecifies the text color of an element
background-color{color} backgroundSpecifies the background color of an element
border-color{color} borderSets the color of all four borders
border-top-color{color} top-borderSets the color of the top border
border-bottom-color{color} bottom-borderSets the color of the bottom border
border-left-color{color} left-borderSets the color of the left border
border-right-color{color} right-borderSets the color of the right border
caret-color{color} caretSpecifies the color of the cursor (caret) in inputs, textareas, or any element that is editable
column-rule-color{color} column-ruleSpecifies the color of the rule between columns
outline-color{color} outlineSets the color of an outline
text-decoration-color{color} text-decorationSpecifies the color of the text-decoration

Very enticing... But I still feel reluctant about the size...

No Worries! A small postcss plugin is currently in the works which will eliminate the need for the above files. This repository mainly houses the code for generating the colours and testing its feasibility. The Postcss plugin will also provide multiple language support.


Footnotes

1: A system is perceptually uniform if a small perturbation to a component value is approximately equally perceptible across the range of that value. In terms of colour spaces, a small degree of change between hues across the range (0°-360°) correspond to a similar increase in chroma and lightness that are perceptually equivalent under natural vision.

2: Abbreviation for Internationalisation, which in this context, refers to multilingual compatibility.

3: Modern Color Models - Munsell Color System. http://www.handprint.com/HP/WCL/color7.html#MUNSELL

4: Modern Color Models - Swedish Natural Color System. http://www.handprint.com/HP/WCL/color7.html#NCS