diff --git a/Project.toml b/Project.toml index a2e70d7..cc3885b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ColorVectorSpace" uuid = "c3611d14-8923-5661-9e6a-0046d554d3a4" -version = "0.10.0" +version = "0.10.1" [deps] ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" @@ -11,10 +11,10 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" TensorCore = "62fd8b95-f654-4bbd-a8a5-9c27f68ccd50" [compat] -ColorTypes = "0.10, 0.11" +ColorTypes = "0.12" FixedPointNumbers = "0.8.2" Requires = "1" -SpecialFunctions = "0.8, 0.9, 0.10, 1, 2.0" +SpecialFunctions = "1, 2" TensorCore = "0.1" julia = "1" diff --git a/src/ColorVectorSpace.jl b/src/ColorVectorSpace.jl index 02e4113..c048951 100644 --- a/src/ColorVectorSpace.jl +++ b/src/ColorVectorSpace.jl @@ -275,6 +275,10 @@ end (-)(a::TransparentRGB, b::TransparentRGB) = _mapc(rettype(-, a, b), -, a, b) # New multiplication operators +function (⋅)(x::C, y::C) where C <: AbstractRGB # ambiguity fix + T = acctype(eltype(x), eltype(y)) + (T(red(x))*T(red(y)) + T(green(x))*T(green(y)) + T(blue(x))*T(blue(y)))/3 +end function (⋅)(x::AbstractRGB, y::AbstractRGB) T = acctype(eltype(x), eltype(y)) (T(red(x))*T(red(y)) + T(green(x))*T(green(y)) + T(blue(x))*T(blue(y)))/3 @@ -418,6 +422,7 @@ Base.zero(a::RGBRGB) = zero(typeof(a)) *(a::RGBRGB, α::Real) = α*a /(a::RGBRGB, α::Real) = (1/α)*a +⊗(a::C, b::C) where C<:AbstractRGB = invoke(⊗, Tuple{AbstractRGB,AbstractRGB}, a, b) # ambiguity function ⊗(a::AbstractRGB, b::AbstractRGB) ar, ag, ab = red(a), green(a), blue(a) br, bg, bb = red(b), green(b), blue(b) diff --git a/test/runtests.jl b/test/runtests.jl index 6088c73..e229af3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,10 +82,10 @@ ColorTypes.comp2(c::RGBA32) = alpha(c) @test @inferred(convert(Gray{typeof(x)}, x)) === @inferred(convert(Gray, x)) === Gray(x) @test @inferred(convert(RGB{typeof(x)}, x)) === @inferred(convert(RGB, x)) === RGB(x, x, x) # These should be fixed by a future release of ColorTypes - @test_broken @inferred(convert(AGray{typeof(x)}, x)) === @inferred(convert(AGray, x)) === AGray(x, 1) - @test_broken @inferred(convert(ARGB{typeof(x)}, x)) === @inferred(convert(ARGB, x)) === ARGB(x, x, x, 1) - @test_broken @inferred(convert(GrayA{typeof(x)}, x)) === @inferred(convert(GrayA, x)) === GrayA(x, 1) - @test_broken @inferred(convert(RGBA{typeof(x)}, x)) === @inferred(convert(RGBA, x)) === RGBA(x, x, x, 1) + @test @inferred(convert(AGray{typeof(x)}, x)) === @inferred(convert(AGray, x)) === AGray(x, 1) + @test @inferred(convert(ARGB{typeof(x)}, x)) === @inferred(convert(ARGB, x)) === ARGB(x, x, x, 1) + @test @inferred(convert(GrayA{typeof(x)}, x)) === @inferred(convert(GrayA, x)) === GrayA(x, 1) + @test @inferred(convert(RGBA{typeof(x)}, x)) === @inferred(convert(RGBA, x)) === RGBA(x, x, x, 1) end end