coloraide

A library to aid in using colors

MIT License

Downloads
15.8K
Stars
191
Committers
2

Bot releases are hidden (Show)

coloraide - 1.6

Published by facelessuser over 1 year ago

1.6

  • NEW: Add rec2100-hlg color space.
  • BREAKING: rec2100pq should have been named rec2100-pq for consistency. It has been renamed to rec2100-pq and
    serializes with the CSS ID of --rec2100-pq. This is likely to have little impact on most users.
coloraide - 1.5

Published by facelessuser almost 2 years ago

1.5

  • NEW: Formally add support for Python 3.11.
  • NEW: Add support for custom domains when interpolating.
  • NEW: set() can now take a dictionary of channels and values and set multiple channels at once.
  • NEW: get() can now take a list of channels and will return a list of those channel values.
  • ENHANCE: Simplify some type annotation syntax.
  • ENHANCE: Some minor performance enhancements.
  • FIX: Fix OkLCh CSS parsing.
coloraide - 1.4

Published by facelessuser about 2 years ago

1.4

  • NEW: A color space can now declare its dynamic range. By default, spaces are assumed to be SDR, but can declare
    themselves as HDR, or something else. This allows ColorAide to make decisions based on a color's dynamic range.
  • NEW: Add channel aliases for IPT and IPT-like color spaces (IgPgTg and ICtCp): intensity, protan, and
    tritan.
  • FIX: The ICtCp and oRGB space would return the Lab-ish equivalents for a and b in reverse order if calling
    Labish.labish_names. This was not actually called anywhere in the code, but is now fixed for any future cases that
    may require calling it.
  • FIX: Undefined channels should be ignored when clipping a color.
  • FIX: Do not apply SDR shortcuts in gamut mapping when fitting in a non-SDR color gamut, such as HDR.
coloraide - 1.3

Published by facelessuser about 2 years ago

1.3

  • ENHANCE: Color vision deficiency filters can now be instantiated with different default methods for severe and
    anomalous cases.
  • FIX: Fix premultiplication handling when using compose.
coloraide - 1.2

Published by facelessuser about 2 years ago

1.2

  • NEW: Add new monotone interpolation method.
  • ENHANCE: Better extrapolation past end of spline.
  • FIX: Small speed up in natural spline calculation.
  • FIX: Fix import that should have been relative, not absolute.
coloraide - 1.1

Published by facelessuser about 2 years ago

1.1

  • NEW: Slight refactor of interpolation plugin so that common code does not need to be duplicated, and the
    interpolate method no longer needs to accept an easing parameter as the plugin class exposes a new ease method
    to automatically acquire the proper, specified easing function and apply it.
  • NEW: Functions built upon interpolation can now use a new extrapolate parameter to enable extrapolation if
    interpolation inputs exceed 0 - 1. point will be passed to Interpolator.interpolate un-clamped if extrapolate is
    enabled. If a particular interpolation plugin needs to do additional work to handle extrapolation, they can check
    self.extrapolate to know whether extrapolation is enabled.
  • NEW: Implement and provide the following easing functions as described in the CSS Easing Level 1 spec:
    cubic_bezier, ease, ease_in, ease_out, and ease_in_out. Also provide a simple linear easing function.
  • New: Add natural and catrom cubic spline options for interpolation. The catrom (Catmull-Rom) spline requires
    the plugin to be registered in order to use it.
  • FIX: Due to floating point math, B-spline could sometimes return an interpolation of fully opaque colors with an
    imperceptible amount of transparency. If alpha is very close (#!py3 1e-6) to being opaque, just round it to opaque.
  • FIX: An easing function's output should not be clamped, only the input, and that only needs to occur on the
    the outer range of an entire interpolation.
coloraide - 1.0

Published by facelessuser about 2 years ago

1.0

Note Stable Release!
Checkout migration guide if you were an early adopter.

  • NEW: Bezier interpolation dropped for B-spline which provides much better interpolation.
  • NEW: All new interpolation methods now support hue fix-ups: shorter, longer, increasing, decreasing,
    and specified.
  • NEW: Interpolation is now exposed as a plugin to allow for expansion.
  • FIX: Fixed an issue related to premultiplication and undefined alpha channels.
coloraide - 1.0rc1

Published by facelessuser about 2 years ago

1.0rc1

Warning Plugin Refactor
For more flexibility there was one final rework of plugins. Registering requires all plugins to be instantiated
before being passed into Color.register, but this allows a user redefine some defaults of certain plugins.

coloraide.ColorAll was moved to coloraide.everythng.ColorAll to avoid allocating plugins when they are not
desired.

In the process, we also renamed a number of plugin classes for consistency and predictability, details found below.

  • NEW: Updated some class names for consistency and predictability. XyY --> xyY, Din99o --> DIN99o, SRGB
    --> sRGB, and ORGB --> oRGB.

    Lastly, LCh should be the default casing convention. This convention will be followed unless a spec mentions
    otherwise. Changes: Lch --> LCh, LchD65 --> LChD65, Oklch --> OkLCh, Lchuv --> LChuv, Lch99o -->
    LCh99o, LchChroma --> LChChroma, OklchChroma --> OkLChChroma, and Lchish --> LChish.

  • NEW: Updated migration guide with recent plugin changes.

  • NEW: coloraide.ColorAll renamed and moved to coloraide.everything.ColorAll. This prevents unnecessary
    inclusion and allocation of objects that are not desired.

  • NEW: Default Color object now only registers bradford CAT by default, all others must be registered
    separately, or coloraide.everything.Color could be used.

  • NEW: All plugin classes must be instantiated when being registered. This allows some plugins to be instantiated
    with different defaults. This allows some plugins to be configured with different defaults.

    # Before change:
    Color.register([Plugin1, Plugin2])
    
    # After change:
    Color.register([Plugin1(), Plugin2(optional_parm=True)])
    
coloraide - 1.0b3

Published by facelessuser over 2 years ago

1.0b3

  • FIX: Fixed the bad CAT16 matrix for chromatic adaptation.
  • FIX: Small fix related to how CAT plugin classes are defined for better abstraction.
  • FIX: Restrict optional keywords in Color.register() and Color.deregister() to keyword only parameters.
coloraide - 1.0b2

Published by facelessuser over 2 years ago

1.0b2

"Breaking Changes"
1.0b2 only introduces one more last breaking change that was forgotten in 1.0b1.

  • BREAK: Remove filters parameter on new class instantiation.
  • NEW: Added new migration guide to the documentation to help early adopters move to the 1.0 release.
  • NEW: Added HPLuv space described in the HSLuv spec.
  • NEW: Added new color spaces: ACES 2065-1, ACEScg, ACEScc, and ACEScct.
  • NEW: Contrast is now exposed as a plugin to allow for future expansion of approaches. While there is currently
    only one approach, methods can be selected via the method attribute.
  • NEW: Add new random method for generating a random color for a given color space.
coloraide - 1.0b1

Published by facelessuser over 2 years ago

1.0b1

Breaking Changes
1.0b1 introduces a number of breaking changes. As we are very close to releasing the first stable release, we've
taken opportunity to address any issues related to speed and usability. While this is unfortunate for early
adopters, we feel that in the long run that these changes will make ColorAide a better library. We've also added new
a new Bezier interpolation method and added many more color spaces!

  • BREAK: The coloraide.Color object now only registers a subset of the available color spaces and ∆E algorithms in
    order to create a lighter default color object. coloraide.ColorAll has been provided for a quick way to get access
    to all available color spaces and plugins. Generally, it is recommend to subclass Color and register just what is
    desired.

  • BREAK: Reworked interpolation:

    • interpolate and steps functions are now @classmethods. This alleviates the awkward handling of interpolating
      colors greater than 2. Before, the first color always had to be an instance and then the rest had to be fed into
      that instance, now the the methods can be called from the base class or an instance with all the colors fed in
      via a list. Only the colors in the list will be evaluated during interpolation.
    • Piecewise object has been removed.
    • stop objects are used to wrap colors to apply a new color stop.
    • easing functions can be supplied in the middle of two colors via the list input.
    • hint function has been provided to simulate CSS color hinting. hint returns an easing function that modifies
      the midpoint to the specified point between two color stops.
    • A new bezier interpolation method has been provided. When using interpolate, steps, or mix the interpolation
      style can be changed via the method parameter. bezier and linear are available with linear being the
      default.
  • BREAK: Dictionary input/output now matches the following format (where alpha is optional):

    {"space": "name", "coords": [0, 0, 0], "alpha": 1}
    

    This allows for quicker processing and less complexity dealing with channel names and aliases.

  • BREAK: The CSS Level 4 Color spec has accepted our proposed changes to the gamut mapping algorithm. With this
    change, the oklch-chroma gamut mapping algorithm is now compliant with the CSS spec, and css-color-4 is no longer
    needed. If you were experimenting with css-color-4, please use oklch-chroma instead. The algorithm is faster and
    does not have the color banding issue that css-color-4 had, and it is now exactly the same as the CSS spec.

  • BREAK: New breaking change. Refactor of Space plugins. Space plugins are no longer instantiated which cuts
    down on overhead lending to better performance. BOUNDS and CHANNEL_NAMES attributes were combined into one
    attribute called CHANNELS which serves the same purpose as the former attributes. Space plugins also no longer
    need to define channel property accessors as those are handled through CHANNELS in a more generic way. This is a
    breaking change for any custom plugins.

    Additionally, the Space plugin's null_adjust method has been renamed as normalize matching its functionality
    and usage in regards to the Color object. It no longer accepts color coordinates and alpha channel coordinates
    separately, but will receive them as a single list and return them as such.

  • BREAK: Color's fit and clip methods now perform the operation in place, modifying the current color
    directly. The in_place parameter has been removed. To create a new color when performing these actions, simply clone
    the color first: #!py color.clone().clip().

  • BREAK: Remove deprecated dynamic properties which helps to increase speed by removing overhead on class property
    access.

  • BREAK: Remove deprecated dynamic properties which helps to increase speed by removing overhead on class property
    access. Use indexing instead: color['red'] or color[0].

  • BREAK: Remove deprecated coords() method. Use indexing and slices instead: color[:-1].

  • NEW: Update lch(), lab(), oklch(), and oklab() to optionally support percentages for lightness, chroma, a,
    and b. Lightness is no longer enforced to be a percentage in the CSS syntax and these spaces will serialize as a
    number by default instead. Optionally, these forms can force a percentage output via the to_string method when using
    the percentage option. Percent ranges roughly correspond with the Display P3 gamut per the CSS specification.

    Additionally, CSS color spaces using the color() format as an input will translate using these same ranges if the
    channels are percentages. hue will also be respected and treated as 0 - 360 when using a percentage.

    Non-CSS color spaces will also respect their defined ranges when using percentages in the color() form.

  • NEW: Add silent option to deregister so that if a proper category is specified, and the plugin does not exit,
    the operation will not throw an error.

  • NEW: Add new color spaces: display-p3-linear, a98-rgb-linear, rec2020-linear, prophoto-rgb-linear, and
    rec2100pq, hsi, rlab, hunter-lab, xyy, prismatic, orgb, cmy, cmyk, ipt, and igpgtg.

  • NEW: Monochromatic color harmony must also be performed in a cylindrical color space to make achromatic detection
    easier. This means all color harmonies now must be performed under a cylindrical color space.

  • NEW: Use Lab D65 for ∆E 2000, ∆E 76, ∆E HyAB, Euclidean distance, and Lch D65 for Lch Chroma gamut mapping. Lab
    D65 is far more commonly used for the aforementioned ∆E methods. Lch Chroma gamut mapping, which uses ∆E 2000 needs to
    use the same D65 white point to avoid wasting conversion time.

  • FIX: Better handling of monochromatic harmonies that are near white or black.

  • FIX: Small fix to steps ∆E logic.

coloraide - 0.18.1

Published by facelessuser over 2 years ago

0.18.1

  • FIX: Fix issue where when generating steps with a max_delta_e, the ∆E was reduced too much causing additional,
    unnecessary steps along with longer processing time.
coloraide - 0.18.0

Published by facelessuser over 2 years ago

0.18.0

  • NEW: Allow dictionary input to use aliases in the dictionary.
  • FIX: If too many channels are given to a color space via raw data, ensure the operation fails.
  • FIX: Sync up achromatic logic of the Okhsl and Okhsv normalize function with the actual conversion algorithm.
  • FIX: Regression that caused cat16 not to work due to a misnamed variable.
coloraide - 0.17.0

Published by facelessuser over 2 years ago

0.17.0

Warning: Interpolations Are Now Premultiplied
ColorAide has moved to make premultiplication the default for interpolation methods such as mix, steps, and
interpolate. The aim is to provide more accurate interpolation when using transparent colors. In cases where
premultiplication is not desired, it can be disabled by setting it to #!py3 False. There are real reasons to do so
as it may be desirous to mimic an old implementation that has always used naive interpolation of transparent colors.

Additionally, in the past, premultiplication was not really documented as it had not been fully tested.
Premultiplication is now covered in the documentation.

  • NEW: All mixing/interpolation methods will use #!py3 premultiply=True by default.
  • NEW: Allow aliases in interpolation's progress mappings.
  • FIX: Fix premultiplication when alpha is undefined.
  • FIX: Fix some potential issues in some matrix math logic.
  • FIX: #!py Piecewise() object didn't default all the non-required parameters to #!py None as documented.
coloraide - 0.16.0

Published by facelessuser over 2 years ago

0.16.0

Warning: Deprecations
In interest of speed, and due to the overhead inflicted on every class attribute access, we've decided to deprecate
dynamic properties. This includes dynamic color properties (e.g. Color.red) and dynamic ∆E methods (e.g.
Color.delta_e_2000()). As far as color channel coordinate access is concerned, we've reworked a faster more useful
approach. ∆E already has a suitable replacement and will be the only approach moving forward.

  1. Use of delta_e_<method> is deprecated. Users should use the already available delta_e(color, method=name)
    approach when using non-default ∆E methods.

  2. Color channel access has changed. Dynamic channel properties have been deprecated. Usage of Color.coords() has
    also been deprecated. All channels can now easily be accessed with indexing. Color.get() and Color.set()
    have not changed.

    • You can index with numbers: Color[0].
    • You can index with channel names: Color['red'].
    • You can slice to get specific color coordinates: Color[:-1].
    • You can get all coordinates: Color[:] or list(Color).
    • You can even iterate coordinates: [c for c in Color].
    • Indexing also supports assignment: Color[0] = 1 or Color[:3] = [1, 1, 1].

Please consider updating usage to utilize the suggested approaches. The aforementioned methods will be removed
sometime before the 1.0 release.

  • NEW: Color objects are now indexable and channels can be retrieved using either numbers or strings, e.g.,
    #!py3 Color[0] or #!py3 Color['red']. Slicing and assignments via slicing are also supported:
    #!py3 Color1[:] = Color2[:].
  • NEW: Color.coords(), dynamic color properties, and dynamic ∆E methods are all deprecated.
  • NEW: Input method names for distancing, gamut mapping, compositing, and space methods are now case sensitive.
    There were inconsistencies in some places, so it was opted to make all case sensitive.
  • NEW: The ability to create color harmonies has been added via the new harmony() method. Also, the default color
    space used to calculate color harmonies can be overridden by the class property HARMONY.
  • NEW: Add new support for filters added via the filter() method. Filters include the W3C Filter Effects Level 1
    and color vision deficiency simulation.
  • NEW: Some performance enhancements in conversions.
  • NEW: Chromatic adaptation is now exposed as a plugin. New CAT plugins can be created externally and registered.
  • FIX: Okhsl and Okhsv handling of achromatic values during conversion.
coloraide - 0.15.1

Published by facelessuser over 2 years ago

0.15.1

  • FIX: Fix an issue related to matching colors in a buffer at a given offset.
coloraide - 0.15.0

Published by facelessuser over 2 years ago

Warning:
No changes in the public API have changed, but type annotations have. If you were importing type annotations, you
will have to update them.

Also, if any undocumented math related methods were accessed (for plugins or otherwise) they've been moved to
coloraide.algebra

  • NEW: A number of performance improvements.
  • NEW: Regenerate all matrices with our own matrix tools so that there is consistency between precision of
    pre-generated matrices and on-the-fly matrix generation. Reduces some noise in a few color space transforms.
  • NEW: Changes to type annotations. Mutable<type>, where type is either Matrix, Vector, or Array, are simply
    known as <type>. Types previously specified as <type>, where type is either Matrix, Vector, or Array, are
    now known as <type>Like. The types are expected to be mutable lists, anything else is noted as "like".
  • NEW: All matrix and math utilities have been moved to coloraide.algebra.
  • FIX: Fix rare issue where precision adjustment could fail.
  • FIX: Fix matrix divide logic when dividing a number or vector by a matrix. There are no actual usage of these
    cases in the code but they were fixed in case they are used in the future.
coloraide - 0.14.2

Published by facelessuser over 2 years ago

0.14.2

  • FIX: Fix rare issue where precision adjustment could fail.
  • FIX: Fix util.divide logic when dividing a number or vector by a matrix. There are no actual usage of these
    cases in the code but fixed in case they are used in the future.
  • FIX: Minor performance improvements.
coloraide - 0.14.1

Published by facelessuser over 2 years ago

0.14.1

  • FIX: Fix bug related to parsing strings without full matching.
coloraide - 0.14.0

Published by facelessuser over 2 years ago

0.14.0

Note
No changes should break existing color space plugins. Moved objects and references are still also available in old
locations, and new functionality is implemented in such a way as to not break existing plugins, but plugins should
be updated as sometime before the 1.0 release, such legacy access will be removed.

  • NEW: Faster parsing. Instead of parsing the color(space ...) format each a different color space is evaluated,
    generically parse it once and then associate it with a registered color space. If a color space wishes to opt out of
    the color(space ...) input format, the space should set COLOR_FORMAT to False. This means there is no need to
    call super.match() when overriding Color.match() to ensure support for the color(space ...) format as it will be
    handled unless COLOR_FORMAT is turned off. DEFAULT_MATCH usage should also be discontinued as it now does nothing.
  • NEW: Other speed optimizations.
  • NEW: All CSS parsing and serialization is now contained in a single module at coloraide.css. This simplifies
    the current color space classes greatly when it comes to supporting CSS specific formats.
  • NEW: Move our white space mapping to the cat module as it makes more sense there.
  • NEW: GamutBound, GamutUnbound, and associated flags are now contained under coloraide.gamut.bounds.
  • NEW: normalize will also remove masked values to properly adjust the color.
  • FIX: Compositing and blending should not "fit" colors before applying, it is only specified that the range should
    be clamped at the end of blending.
  • FIX: Fix issue where a subclassed Color() object could not recognize the base class or other subclasses.
Package Rankings
Top 6.23% on Pypi.org
Top 43.41% on Conda-forge.org
Badges
Extracted from project README
Donate via PayPal Build Coverage Status PyPI Version PyPI Downloads PyPI - Python Version