diff --git a/src/ColorVectorSpace.jl b/src/ColorVectorSpace.jl index c048951..b51c96f 100644 --- a/src/ColorVectorSpace.jl +++ b/src/ColorVectorSpace.jl @@ -30,7 +30,7 @@ isdefined(Base, :get_extension) || using Requires export RGBRGB, complement, nan, dotc, dot, ⋅, hadamard, ⊙, tensor, ⊗, norm, varmult, stdmult -MathTypes{T,C<:Union{AbstractGray{T},AbstractRGB{T}}} = Union{C,TransparentColor{C,T}} +MathTypes{T,C<:Union{AbstractGray{T},AbstractRGB{T},CMY}} = Union{C,TransparentColor{C,T}} ## Version compatibility with ColorTypes ### TODO: Remove the definitons other than `one` when dropping ColorTypes v0.10 support @@ -161,6 +161,7 @@ channels(c::AbstractGray) = (gray(c),) channels(c::TransparentGray) = (gray(c), alpha(c)) channels(c::AbstractRGB) = (red(c), green(c), blue(c)) channels(c::TransparentRGB) = (red(c), green(c), blue(c), alpha(c)) +channels(c::CMY) = (cyan(c), magenta(c), yellow(c)) if reinterpret(N0f16, 0xBADb)^2 === N0f16(float(reinterpret(N0f16, 0xBADb))^2) function _mul(x::N0f8, y::N0f8) @@ -291,6 +292,14 @@ end dotc(x::T, y::T) where {T<:AbstractRGB} = 0.200f0 * acc(red(x))*acc(red(y)) + 0.771f0 * acc(green(x))*acc(green(y)) + 0.029f0 * acc(blue(x))*acc(blue(y)) dotc(x::AbstractRGB, y::AbstractRGB) = dotc(promote(x, y)...) +# CMY +function (/)(c::CMY, f::AbstractFloat) + r = oneunit(divtype(eltype(c), typeof(f))) / f + _mapc(rettype(/, c, f), v -> v * r, c) +end +(+)(a::CMY, b::CMY) = _mapc(rettype(+, a, b), +, a, b) +(-)(a::CMY, b::CMY) = _mapc(rettype(-, a, b), -, a, b) + # Scalar Gray const unaryops = (:~, :conj, :abs, :sin, :cos, :tan, :sinh, :cosh, :tanh,