uni_color_model 0.1.0
uni_color_model: ^0.1.0 copied to clipboard
A color structure for represent any color: model (CMYK, RGB, HSL, etc.), alpha, depth per channel, view, etc. Сan transform the structures.
Uni(fying) Color Model #
Unified color structure for represent any color: model (CMYK, RGB, HSL, etc.), with or without alpha, depth per channel, channel-by-channel view (hex, dec, int, double, percentage. string), etc. Сan transform the structures.
The easy-to-use and well-tested package. Feel free to use it in your awesome projects.
When you need to determine the color value by name or vice versa, refer to the package UniColorName.
If you're looking for a structured color palette, look at UniColorPalette.
Android | iOS | Linux | MacOS | Web | Windows | |
---|---|---|---|---|---|---|
✅ | ✅ | ✅ | ✅ | ✘ | ✅ | platform |
Dart | Flutter | |
---|---|---|
✅ | ✅ | SDK |
Share some ❤️ and star repo to support the project.
Usage #
final c = 0x1805db.rgbInt8Color;
print(c.int24Hex);
print(c.hasAlpha);
print('Red channel: #${c.r.hex()}');
1805db
false
Red channel: #18
See also UniColorPalette example/all_palettes
folder with Flutter example that visualize palette.
Color Palettes #
See the package uni_color_palette.
Glossary #
Color depth or Bit depth #
The number of bits per pixel in a bitmap image. List of common depths.
Color Converters #
The formulas for color conversion are easily programmable, but we have many converters. So let's summarize them (TODO):
⬇️ model (channels) |
---|
cmyk |
rgb |
hsl |
hsv |
xyz |
⬇️ num |
---|
double |
int |
⬇️ depth per channel |
---|
1 |
2 |
3 |
4 |
5 |
6 |
... |
⬇️ channel view |
---|
dec |
hex |
percent |
⬇️ alpha (transparency) |
---|
false |
true |
⬇️ structure |
---|
int |
String |
Iterable<double> |
Iterable<int> |
UniColor<double> |
UniColor<int> |
TODO A converter name using as extension and constructing by these schema: color[SourceModel]To[Structure][ResultModel]()
.
For example:
colorRgbToIntCmyk
colorRgbToInt
colorRgbToIntHsl
...
colorRgbToStringCmyk
colorRgbToString
...
colorRgbToUniColorDoubleCmyk
colorRgbToUniColorDouble
...
colorRgbToUniColorIntCmyk
...
colorCmykToIterableDoubleRgb
colorCmykToIterableInt
...
colorRgbToIterableIntHsv
colorXyzToIterableIntXyz
Examples of uses:
// as ARGB model by default
0xFFCC00DE.colorToString();
// represent as XYZ model before transformation
0xCC00DE.model(ColorModel.hsl).colorToString();
// or with same result
0xCC00DE.colorModelHsl.colorToString();
// as ARGB model by default
'ffcc00de'.colorToInt();
// 255 is a max value for the channel for normalize a color to range [0.0; 1.0]
[1, 12, 128].colorToUniColorDouble(255);
// the result will be `(1.0, 1 / 255, 12 / 255, 128 / 255)`
// but in this case
[1, 12, 128].colorToUniColorDouble();
// the result will be `(255.0, 1.0, 12.0, 128.0)`
[0.1, 0.12, 0.128].colorToUniColorInt(255);
// the result for this example: `(255, 0.1 * 255, 0.12 * 255, 0.128 * 255)`
Resources #
Working on this project, I found amazing resources and am grateful to the authors:
- https://thecolorapi.com Pass in any valid color and get conversion into any other format, the name of the color, placeholder images and a multitude of schemes.
- https://colorhexmap.com Get Ready to Explore a World of Color.
- https://canva.com/learn/color-tips 10 color inspiration secrets only designers know about.
- https://canva.com/colors/color-wheel Color theory and the color wheel.
- https://canva.com/learn/100-color-combinations 100 inspiring color combinations & Free color palette generator.
Welcome to Inspiration #
Requests and suggestions are warmly welcome.
Contributions are what make the open-source community such a great place to learn, create, and be inspired.
If this is your first contribution, I'll leave you with some of the best links I've found: they will help you get started or/and become even more efficient.
- Guide to Making a First Contribution. You will find the guide in your native language.
- How to Contribute to Open Source. Longread for deep diving for first-timers and for veterans.
- Summer Guide from Google.
The package UniColorModel is open-source, stable and well-tested. Development happens on GitHub. Feel free to report issues or create a pull-request there.
General questions are best asked on StackOverflow.
And here is a curated list of how you can help:
- Report parts of the documentation that are unclear.
- Fix typos/grammar mistakes.
- Update the documentation or add examples.
- Report bugs and scenarios that are difficult to implement.
- Implement new features by making a pull-request (look below).
TODO (perhaps) #
Once you start using the UniColorModel, it will become easy to choose the functionality to contribute. But if you already get everything you need from this package but have some free time, let me write here what I have planned:
-
Feautures for this package into
README
. -
Dependency to
collection
package. We can do without. -
Check out the Web platform.
-
Generalized to
num
instead ofdouble
andint
? Reason: reduce a count of extensions. -
Converters between palettes.
-
How to define your own map for color palette.
-
Optimize a search.
-
Fuzzy search by name.
-
Fuzzy search by value.
-
Range checker to each model.
-
Autodetect a model when constructing a
Palette
. -
operator[]
for getting a value by color name and vice versa. -
The range of values to check the integrity of the color.
-
A converter name using as extension and constructing by these schema:
color[SourceModel]To[Structure][ResultModel]()
. For example:colorRgbToIntCmyk
. -
Colors with transparent. https://ftp.pwg.org/pub/pwg/candidates/cs-pwgmsn20-20130328-5101.1.pdf
-
Sources for color palettes.
-
Faber Castell palettes. 1
-
Colors from WIKI as palette? 1
-
Construct a palette by color scheme? Complementary, triad, tetrad, analogus, accented, split... 1 2
-
In fashion balance palettes? 1
-
colorhunt.co palettes? 1
-
PANTONE®, RAL®, Dulux®, Copic®, NCS®, HKS® and Prismacolor®. !
-
ZxSpectrum palette 1
-
Freetone. https://en.m.wikipedia.org/wiki/Stuart_Semple#Freetone
-
Color spaces (aka palettes) from https://github.com/fundevogel/we-love-colors.
-
RAL color system. https://en.m.wikipedia.org/wiki/List_of_RAL_colours | https://ral-farben.de/alle-ral-farben 1 2 1 2 all colors or https://ral-farben.de/en/downloads
-
RAL light reflactance values? 1
-
RAL Classic & Design system plus color names. 1
-
RAL Classic, Design, Effect, Plastic P1, Plastic P2.
-
Meaning from ISO 3864?
-
HKS color system. https://en.m.wikipedia.org/wiki/HKS_(colour_system)
-
Natural color system. https://en.m.wikipedia.org/wiki/Natural_Color_System
-
CIE-LAB, CIE-LCH, CIE-LUV, XYY, HUNTER-LAB. 1
-
Color blind friendly palettes. https://commons.wikimedia.org/wiki/Commons:Creating_accessible_illustrations
-
Color characteristics? For ex., LRV: https://en.m.wikipedia.org/wiki/Light_reflectance_value -> https://thelandofcolor.com/lrv-light-reflectance-value-of-paint-colors CR: https://en.m.wikipedia.org/wiki/Color_rendering_index
-
Articles from https://en.m.wikipedia.org/wiki/Index_of_color-related_articles.
-
Tagged color palettes. 1
-
Names in different lanuages? 1
-
Color names for base color? 1
It's just a habit of mine: writing down ideas that come to mind while working on a project. I confess that I rarely return to these notes. But now, hopefully, even if you don't have an idea yet, the above notes will help you choose the suitable "feature" and become a contributor to the open-source community.
Created with ❤️