Update dependency color to v2 #2783
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
1.8→2.1.2Release Notes
halostatue/color (color)
v2.1.2Compare Source
Updated to Contributor Covenant 3.0 and applied updates to several support
documents.
Full coverage of conversion tests. Adds CIELAB
to_yiqand Grayscaleto_xyzmethods. Only YIQ now lacks conversions support. Fixed in [#69][pr-69].
Fix an incorrect conversion of CIELAB colors with low lightness to XYZ, which
caused the Y component to be ~903 times larger than correct. In practice, this
returned unexpectedly bright colours.
This also affected conversion from CIELAB to RGB, CMYK, HSL, YIQ, and
grayscale, which convert from CIELAB to XYZ as an intermediate step.
Reported by @alexwlchan in [#95][issue-95] and fixed in [#96][pr-96].
Fix an incorrect comparison when converting CIE XYZ colors to RGB that could
raise a
NoMethodErrorwhen constructing the RGB value. The conversionincorrectly compared the absolute value of an intermediate value against the
0.0031308 threshold instead of comparing the original value, causing certain
negative values to follow the wrong branch and return complex RGB components.
This also affected conversion from XYZ to CMYK, HSL, and YIK, and from CIELAB
to RGB, HSL, YIQ, and Grayscale -- all of which convert from XYZ to RGB as an
intermediate step.
Reported by @alexwlchan in [#92][issue-92] and fixed in [#93][pr-93].
v2.1.1Compare Source
Color 2.1.1 fixes a bug where
Color::RGB::BlackandColor::RGB::Whiteare nolonger defined automatically because they are part of
color/rgb/colors.Internally, this defines
Color::RGB::Black000andColor::RGB::WhiteFFF.v2.1.0Compare Source
Color 2.1.0 fixes a computation bug where CIE XYZ values were improperly clamped
and adds more Color::XYZ white points for standard illuminants.
Fixes a bug where standard illuminant white points were improperly clamped and
was seen in
Color::RGB#to_labsince CIELAB conversions must go through theXYZ color model. Even though we were using the D65 white point, the Z value
was being clamped to 1.0 instead of the correct value of ≅1.08. Reported by
@r-plus in [#45][issue-45] and fixed in [#45][pr-46].
The resulting Color::LAB values are not exactly the same values under Color
1.8, but they are within fractional differences deemed acceptable.
Added more white points for standard illuminants in the Color::XYZ::WP2
constant. The values here were derived from the
[White points of standard illuminants][wp-std-illuminant] using the
xyYtoXYZconversion formula whereX = (x * Y) / yandZ = ((1 - x - y) * Y) / y. Only the values for CIE 1931 2° were computed.The values for Color::XYZ::D50 and Color::XYZ::D65 were replaced with these
computed values.
v2.0.1Compare Source
Color 2.0.1 is a minor documentation update.
v2.0.0Compare Source
Color 2.0.0 is a major release of the Color library.
💣 Breaking Changes
Color 2.0 contains breaking changes. Functionality previously deprecated has
been removed, but other functionality has been changed or removed as part of
this release without prior warning.
The minimum supported version of Ruby is 3.2.
Color classes are now immutable implementations of Data objects (first
introduced in Ruby 3.2). This will restrict Color 2 from running on versions
of JRuby before JRuby 10.
The constants
Color::COLOR_VERSIONandColor::COLOR_TOOLS_VERSIONhavebeen removed; there is only
Color::VERSION. This reverses a planneddeprecation decision made more than ten years ago that no longer makes sense.
All named color classes at
Colorhave been removed as planned.Color::RGB::BeccaPurplehas been removed as an alias forColor::RGB::RebeccaPurple.The pseudo-constructor
Color.newhas been removed.Color class constructors no longer yield the constructed color if a block is
passed.
Renamed
Color::COLOR_EPSILONandColor::COLOR_TOLERANCEtoColor::EPSILONandColor::TOLERANCE. These aren't private constantsbecause they need to be accessed throughout Color, but they are internal
constants that should not be used outside of the Color library or functions
exposed therein.
PDF format functions
#pdf_filland#pdf_strokehave been removed fromColor::CMYK,Color::Grayscale, andColor::RGB. The supporting internalconstants
Color::<class>::PDF_FORMAT_STRhave also been removed.Palette processing classes,
Color::Palette::AdobeColor,Color::Palette::Gimp, andColor::Palette::MonoContrasthave been removed.Persons interested in using these are encouraged to extract them from
[Color 1.8][color-1.8] and adapt them to use Color 2.0 APIs.
CSS methods (
#css_rgb,#css_rgba,#css_hsl,#css_hsla) have beenreplaced with
#csson color classes that have CSS representations. Theoutput of
#cssdiffers (Color 1.8 used the legacy CSS color formats; Color2.0 uses modern CSS color formats).
Color::GrayScalehas been renamed toColor::Grayscale. The alias constantColor::GreyScalehas been removed.The
#htmlmethod has been removed from all color classes except Color::RGB.Named RGB colors are no longer defined automatically, but must be loaded
explicitly by requiring
color/rgb/colors. This resolves [#30][issue-30]. Theuse of
Color::RGB#extract_colors,Color::RGB.by_hex,Color::RGB.by_name,or
Color::RGB.by_csswill requirecolor/rgb/colorsautomatically as theyrequire the presence of the named colors.
Color:CSS#[]has been removed, as has the containing namespace. It hasalways been a shallow wrapper around
Color::RGB.by_name.🚀 New Features
Color::CIELABandColor::XYZnamespaces have been added. Separateimplementations were submitted by David Heitzman and @stiff (in [#8][pr-8] and
[#11][pr-11]), but I have reworked the code substantially. These
implementations were originally as
Color::LABand include a new contrastcalculation using the ΔE*00 algorithm.
Internal
Updated project structure for how I manage Ruby libraries in 2025. This
includes increased release security (MFA is required for all releases,
automated releases are enabled), full GitHub Actions, Dependabot, Standard
Ruby, and more.
Charles Nutter re-added JRuby support in CI. [#36][pr-36]
Governance
Color 2.0 and later requires that all contributions be signed-off attesting that
the developer created the change and has the appropriate permissions or
ownership to contribute it to this project under the licence terms.
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.