https://github.com/mdgriffith/elm-color
https://github.com/mdgriffith/elm-color
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mdgriffith/elm-color
- Owner: mdgriffith
- License: bsd-3-clause
- Created: 2018-02-08T16:53:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-28T14:09:53.000Z (about 8 years ago)
- Last Synced: 2025-06-04T19:55:37.328Z (about 1 year ago)
- Language: Elm
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# A Common Color
The `Color` type is moving out of core (which makes a lot of sense) in `0.19`, so I wanted to discuss what that means for libraries that use it.
The main benefit of `Color` being in the core library was having a single type that color libraries could use to work with each other. So, let's just standardize over one color type!
Here's what I think it should be:
```elm
type alias Color =
{ red : Float
, green : Float
, blue : Float
, alpha : Float
}
```
Each channel is normalized between 0 and 1.
This package is meant to be a series of convenience functions around this new color type.
The cool part being you can be compatible with this library without having to depend on it.
It uses that type as it's `Color` and includes functions for:
- converting hsl to standard color (i.e. rgb)
- calculating contrast of colors
- simulating vision characteristics (color blindness, etc.)
- mixing two colors using the linearRgb colorspace.
- formatting to css values
- parsing hex values
Both `elm-style-animation` and `style-elements` need to use a `Color` type, but before making that change I wanted to post this here :)