Color Picker C1



Latest version

  1. Color Picker Chart
  2. Color Picker Cnet
  3. Color Picker Chrome Extension
  4. Color Picker Chrome
  5. Color Picker C10
  6. Color Picker Cream

Released:

Color are often divided in cool and warm according to how we perceive them. Greens and blues are cool, whilst reds and yellows are warm. A color picker in JavaScript. Supports adapters for integrating other popular color pickers, and can use native color selection controls. In the public domain under CC0. Donate to me If you like this, consider donating to me to help pay my loans and other costs.

converts and manipulates various color representation (HSL, RVB, web, X11, ...)

Project description

Converts and manipulates common color representation (RGB, HSL, web, …)

Feature

  • Damn simple and pythonic way to manipulate color representation (seeexamples below)
  • Full conversion between RGB, HSL, 6-digit hex, 3-digit hex, human color
  • One object (Color) or bunch of single purpose function (rgb2hex,hsl2rgb …)
  • web format that use the smallest representation between6-digit (e.g. #fa3b2c), 3-digit (e.g. #fbb), fully spelledcolor (e.g. white), following W3C color naming for compatibleCSS or HTML color specifications.
  • smooth intuitive color scale generation choosing N color gradients.
  • can pick colors for you to identify objects of your application.

Installation

You don’t need to download the GIT version of the code as colour isavailable on the PyPI. So you should be able to run:

If you have downloaded the GIT sources, then you could add the colour.pydirectly to one of your site-packages (thanks to a symlink). Or installthe current version via traditional:

And if you don’t have the GIT sources but would like to get the latestmaster or branch from github, you could also:

Or even select a specific revision (branch/tag/commit):

Usage

To get complete demo of each function, please read the source code which isheavily documented and provide a lot of examples in doctest format.

Here is a reduced sample of a common usage scenario:

Instantiation

Let’s create blue color:

Please note that all of these are equivalent examples to create the red color:

Reading values

Several representations are accessible:

And their different parts are also independently accessible, as the differentamount of red, blue, green, in the RGB format:

Or the hue, saturation and luminance of the HSL representation:

A note on the .hex property, it’ll return the smallest valid valuewhen possible. If you are only interested by the long value, use.hex_l:

Modifying color objects

All of these properties are read/write, so let’s add some red to this color:

We might want to de-saturate this color:

And of course, the string conversion will give the web representation which ishuman, or 3-digit, or 6-digit hex representation depending which is usable:

Ranges of colors

You can get some color scale of variation between two Color objects quiteeasily. Here, is the color scale of the rainbow between red and blue:

Color Picker Chart

Or the different amount of gray between black and white:

If you have to create graphical representation with color scalebetween red and green (‘lime’ color is full green):

Notice how naturally, the yellow is displayed in human format and inthe middle of the scale. And that the quite unusual (but compatible)‘chartreuse’ color specification has been used in place of thehexadecimal representation.

Color comparison

Sane default

Color comparison is a vast subject. However, it might seem quite straightforward foryou. Colour uses a configurable default way of comparing color that might suityour needs:

The default comparison algorithm focuses only on the “web” representation which isequivalent to comparing the long hex representation (e.g. #FF0000) or to be morespecific, it is equivalent to compare the amount of red, green, and blue compositionof the RGB representation, each of these value being quantized to a 256 value scale.

This default comparison is a practical and convenient way to measure the actualcolor equivalence on your screen, or in your video card memory.

But this comparison wouldn’t make the difference between a black red, and ablack blue, which both are black:

Customization

But, this is not the sole way to compare two colors. As I’m quite lazy, I’m providingyou a way to customize it to your needs. Thus:

As you might have already guessed, the sane default is RGB_equivalence, so:

Here’s how you could implement your unique comparison function:

Note: When comparing 2 colors, only the equality function of the firstcolor will be used. Thus:

But reverse operation is not equivalent !:

Equality to non-Colour objects

As a side note, whatever your custom equality function is, it won’t beused if you compare to anything else than a Colour instance:

Note that these instances would compare as equal to any other color:

Color

But on another non-Colour object:

Actually, Colour instances will, politely enough, leavethe other side of the equality have a chance to decide of the output,(by executing its own __eq__), so:

And inequality (using __ne__) are also polite:

Picking arbitrary color for a python object

Basic Usage

Sometimes, you just want to pick a color for an object in your applicationoften to visually identify this object. Thus, the picked color should be thesame for same objects, and different for different object:

Of course, although there’s a tiny probability that different strings yield thesame color, most of the time, different inputs will produce different colors.

Advanced Usage

You can customize your color picking algorithm by providing a picker. Apicker is a callable that takes an object, and returns something that canbe instantiated as a color by Color:

You might want to use a particular picker, but enforce how the picker willidentify two object as the same (or not). So there’s a pick_key attributethat is provided and defaults as equivalent of hash method and if hash isnot supported by your object, it’ll default to the str of your object saltedwith the class name.

Thus:

Please make sure your object is hashable or “stringable” before using theRGB_color_picker picking mechanism or provide another color picker. Nearlyall python object are hashable by default so this shouldn’t be an issue (e.g.instances of object and subclasses are hashable).

Neither hash nor str are perfect solution. So feel free to usepick_key at Color instantiation time to set your way to identifyobjects, for instance:

When choosing a pick key, you should closely consider if you want your colorto be consistent between runs (this is NOT the case with the last example),or consistent with the content of your object if it is a mutable object.

Default value of pick_key and picker ensures that the same color willbe attributed to same object between different run on different computer formost python object.

Picker

Color factory

As you might have noticed, there are few attributes that you might want to seeattached to all of your colors as equality for equality comparison support,or picker, pick_key to configure your object color picker.

You can create a customized Color factory thanks to the make_color_factory:

All color created thanks to CustomColor class instead of the default onewould get the specified attributes by default:

Of course, these are always instances of Color class:

Equality was changed from normal defaults, so:

This because the default equivalence of Color was set toHSL_equivalence.

Contributing

Any suggestion or issue is welcome. Push request are very welcome,please check out the guidelines.

Push Request Guidelines

You can send any code. I’ll look at it and will integrate it myself inthe code base and leave you as the author. This process can take time andit’ll take less time if you follow the following guidelines:

  • check your code with PEP8 or pylint. Try to stick to 80 columns wide.
  • separate your commits per smallest concern.
  • each commit should pass the tests (to allow easy bisect)
  • each functionality/bugfix commit should contain the code, tests,and doc.
  • prior minor commit with typographic or code cosmetic changes arevery welcome. These should be tagged in their commit summary with!minor.
  • the commit message should follow gitchangelog rules (check the gitlog to get examples)
  • if the commit fixes an issue or finished the implementation of afeature, please mention it in the summary.

If you have some questions about guidelines which is not answered here,please check the current git log, you might find previous commit thatwould show you how to deal with your issue.

License

Copyright (c) 2012-2017 Valentin Lab.

Licensed under the BSD License.

Changelog

0.1.4 (2017-04-19)

Fix

  • rgb2hsl would produce invalid hsl triplet when red, blue, greencomponent would be all very close to 1.0. (fixes #30) [ValentinLab]

    Typically, saturation would shoot out of range 0.0..1.0. That could thenlead to exceptions being casts afterwards when trying to reconvert thisHSL triplet to RGB values.

0.1.3 (2017-04-08)

Fix

  • Unexpected behavior with != operator. (fixes #26) [Valentin Lab]
  • Added mention of the hex_l property. (fixes #27) [Valentin Lab]

0.1.2 (2015-09-15)

Fix

  • Support for corner case 1-wide range_to color scale. (fixes #18)[Valentin Lab]

0.1.1 (2015-03-29)

Fix

  • Avoid casting an exception when comparing to non-Colour instances.(fixes #14) [Riziq Sayegh]

0.0.6 (2014-11-18)

New

  • Provide all missing 2 function by combination with other existingones (fixes #13). [Valentin Lab]

  • Provide full access to any color name in HSL, RGB, HEX convenienceinstances. [Valentin Lab]

    Now you can call colour.HSL.cyan, or colour.HEX.red for a direct encoding ofhuman colour labels to the 3 representations.

0.0.5 (2013-09-16)

Color Picker Cnet

New

  • Color names are case insensitive. [Chris Priest]

    The color-name structure have their names capitalized. And color namesthat are made of only one word will be displayed lowercased.

Fix

  • Now using W3C color recommandation. [Chris Priest]

    Was using X11 color scheme before, which is slightly different fromW3C web color specifications.

  • Inconsistency in licence information (removed GPL mention). (fixes #8)[Valentin Lab]

  • Removed gitchangelog from setup.py require list. (fixes #9)[Valentin Lab]

0.0.4 (2013-06-21)

New

  • Added make_color_factory to customize some common colorattributes. [Valentin Lab]
  • Pick color to identify any python object (fixes #6) [Jonathan Ballet]
  • Equality support between colors, customizable if needed. (fixes #3)[Valentin Lab]

0.0.3 (2013-06-19)

New

  • Colour is now compatible with python3. [Ryan Leckey]

TODO

  • ANSI 16-color and 256-color escape sequence generation
  • YUV, HSV, CMYK support

Release historyRelease notifications | RSS feed

0.1.5

0.1.4

0.1.3

0.1.2

0.1.1

0.0.6

Color Picker Chrome Extension

0.0.5

0.0.4

0.0.3

0.0.2

0.0.1

Download files

Color Picker Chrome

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for colour, version 0.1.5
Filename, sizeFile typePython versionUpload dateHashes
Filename, size colour-0.1.5-py2.py3-none-any.whl (23.8 kB) File type Wheel Python version py2.py3 Upload dateHashes
Filename, size colour-0.1.5.tar.gz (24.8 kB) File type Source Python version None Upload dateHashes
ClosePicker

Hashes for colour-0.1.5-py2.py3-none-any.whl

Hashes for colour-0.1.5-py2.py3-none-any.whl
AlgorithmHash digest
SHA25633f6db9d564fadc16e59921a56999b79571160ce09916303d35346dddc17978c
MD59904afaee027aa215976ec87a30e27be
BLAKE2-2567446e81907704ab203206769dee1385dc77e1407576ff8f50a0681d0a6b541be
Close

Hashes for colour-0.1.5.tar.gz

Hashes for colour-0.1.5.tar.gz
AlgorithmHash digest
SHA256af20120fefd2afede8b001fbef2ea9da70ad7d49fafdb6489025dae8745c3aee
MD55f473c29e0c867ce0241ddba8cd552d6
BLAKE2-256a0d45911a7618acddc3f594ddf144ecd8a03c29074a540f4494670ad8f153efe

C1ColorPicker コントロールを使用して、専門的にデザインされたパレットから色を選択したり、透明度をサポートした独自のカスタムカラーを作成することができます。

For projects that support PackageReference, copy this XML node into the project file to reference the package.
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Dependencies

    • C1.WPF.Core.Ja(= 5.0.20203.37)
    • C1.WPF.Input.Ja(= 5.0.20203.37)
    • C1.WPF.TabControl.Ja(= 5.0.20203.37)

Used By

NuGet packages (1)

Showing the top 1 NuGet packages that depend on C1.WPF.ColorPicker.Ja:

PackageDownloads
C1.WPF.Pivot.Ja

GitHub repositories

This package is not used by any popular GitHub repositories.

Color Picker C10

Version History

Color Picker Cream

VersionDownloadsLast updated
5.0.20203.37 103 12/23/2020