Skip to content

Commit bf6a78a

Browse files
authored
Version 0.9.4 (#163)
This adds the support for ColorTypes v0.11.
1 parent 4b69dc1 commit bf6a78a

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1111
TensorCore = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50"
1212

1313
[compat]
14-
ColorTypes = "0.10"
14+
ColorTypes = "0.10, 0.11"
1515
FixedPointNumbers = "0.8.2"
1616
SpecialFunctions = "0.8, 0.9, 0.10, 1"
1717
TensorCore = "0.1"

src/ColorVectorSpace.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export RGBRGB, complement, nan, dotc, dot, ⋅, hadamard, ⊙, tensor, ⊗, norm
3232
MathTypes{T,C} = Union{AbstractRGB{T},TransparentRGB{C,T},AbstractGray{T},TransparentGray{C,T}}
3333

3434
## Version compatibility with ColorTypes
35+
### TODO: Remove the definitons other than `one` when dropping ColorTypes v0.10 support
3536

3637
if !hasmethod(zero, (Type{TransparentGray},))
3738
zero(::Type{C}) where {C<:TransparentGray} = C(0,0)
@@ -40,7 +41,7 @@ if !hasmethod(zero, (Type{TransparentGray},))
4041
zero(p::Colorant) = zero(typeof(p))
4142
end
4243

43-
if !hasmethod(one, (Type{TransparentGray},))
44+
if !hasmethod(one, (Type{TransparentGray},)) # specification change is planned for ColorTypes v0.12
4445
Base.one(::Type{C}) where {C<:TransparentGray} = C(1,1)
4546
Base.one(::Type{C}) where {C<:AbstractRGB} = C(1,1,1)
4647
Base.one(::Type{C}) where {C<:TransparentRGB} = C(1,1,1,1)
@@ -53,6 +54,16 @@ if !hasmethod(isfinite, (Colorant,))
5354
isnan(c::Colorant) = mapreducec(isnan, |, false, c)
5455
end
5556

57+
if which(<, Tuple{AbstractGray,AbstractGray}).module === Base
58+
(<)(g1::AbstractGray, g2::AbstractGray) = gray(g1) < gray(g2)
59+
(<)(c::AbstractGray, r::Real) = gray(c) < r
60+
(<)(r::Real, c::AbstractGray) = r < gray(c)
61+
end
62+
if !hasmethod(isless, Tuple{AbstractGray,Real})
63+
isless(c::AbstractGray, r::Real) = isless(gray(c), r)
64+
isless(r::Real, c::AbstractGray) = isless(r, gray(c))
65+
end
66+
5667
if isdefined(ColorTypes, :nan)
5768
using ColorTypes: nan
5869
else
@@ -291,16 +302,6 @@ min(a::AbstractGray, b::Number) = min(promote(a,b)...)
291302
atan(x::AbstractGray, y::AbstractGray) = atan(gray(x), gray(y))
292303
hypot(x::AbstractGray, y::AbstractGray) = hypot(gray(x), gray(y))
293304

294-
if which(<, Tuple{AbstractGray,AbstractGray}).module === Base # planned for ColorTypes 0.11
295-
(<)(g1::AbstractGray, g2::AbstractGray) = gray(g1) < gray(g2)
296-
(<)(c::AbstractGray, r::Real) = gray(c) < r
297-
(<)(r::Real, c::AbstractGray) = r < gray(c)
298-
end
299-
if !hasmethod(isless, Tuple{AbstractGray,Real}) # planned for ColorTypes 0.11
300-
isless(c::AbstractGray, r::Real) = isless(gray(c), r)
301-
isless(r::Real, c::AbstractGray) = isless(r, gray(c))
302-
end
303-
304305
dotc(x::C, y::C) where {C<:AbstractGray} = acc(gray(x))*acc(gray(y))
305306
dotc(x::AbstractGray, y::AbstractGray) = dotc(promote(x, y)...)
306307

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ ColorTypes.comp2(c::RGBA32) = alpha(c)
590590
@test complement(Gray(0.2)) === Gray(0.8)
591591
@test complement(AGray(0.2f0, 0.7f0)) === AGray(0.8f0, 0.7f0)
592592
@test complement(GrayA{N0f8}(0.2, 0.7)) === GrayA{N0f8}(0.8, 0.7)
593-
@test_broken complement(Gray24(0.2)) === Gray24(0.8)
594-
@test_broken complement(AGray32(0.2, 0.7)) === AGray32(0.8, 0.7)
593+
@test complement(Gray24(0.2)) === Gray24(0.8)
594+
@test complement(AGray32(0.2, 0.7)) === AGray32(0.8, 0.7)
595595

596596
@test complement(RGB(0, 0.3, 1)) === RGB(1, 0.7, 0)
597597
@test complement(ARGB(0, 0.3f0, 1, 0.7f0)) === ARGB(1, 0.7f0, 0, 0.7f0)

0 commit comments

Comments
 (0)