yannickl / DynamicColor

Yet another extension to manipulate colors easily in Swift and SwiftUI
http://cocoadocs.org/docsets/DynamicColor
MIT License
3k stars 141 forks source link

Add support for grayscale modes #55

Closed regexident closed 4 years ago

regexident commented 4 years ago

The current implementation of final func grayscaled() -> DynamicColor uses the HSL lightness as as measurement of lightness.

While this is computationally convenient it does not provide a good match for the human perception of lightness.

Relative luminance (the Y in XYZ) provides a much more accurate measure.

This PR adds support for specifying which color space (i.e. xyz, hsl, rgb, hsv) to be used for grayscaling, defaulting to .lightness (aka HSL) for the sake of not introducing a breaking-change.

⚠️ Depends on https://github.com/yannickl/DynamicColor/pull/56

codecov[bot] commented 4 years ago

Codecov Report

Merging #55 into master will increase coverage by 0.19%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #55      +/-   ##
==========================================
+ Coverage   93.04%   93.24%   +0.19%     
==========================================
  Files          14       14              
  Lines         374      385      +11     
==========================================
+ Hits          348      359      +11     
  Misses         26       26
Flag Coverage Δ
#ios 93.24% <100%> (+0.19%) :arrow_up:
#osx 5.97% <0%> (-0.18%) :arrow_down:
Impacted Files Coverage Δ
Sources/Utils.swift 100% <ø> (ø) :arrow_up:
Sources/DynamicColor+RGBA.swift 100% <100%> (ø) :arrow_up:
Sources/DynamicColor+Deriving.swift 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1e85f94...5c7d732. Read the comment docs.

yannickl commented 4 years ago

Looks good to me, thanks!