@@ -31,6 +31,30 @@ export RGBRGB, nan, dotc, dot, ⋅, hadamard, ⊙, tensor, ⊗, norm, varmult
3131
3232MathTypes{T,C} = Union{AbstractRGB{T},TransparentRGB{C,T},AbstractGray{T},TransparentGray{C,T}}
3333
34+ # # Version compatibility with ColorTypes
35+
36+ if ! hasmethod (zero, (Type{AGray{N0f8}},))
37+ zero (:: Type{C} ) where {C<: TransparentGray } = C (0 ,0 )
38+ zero (:: Type{C} ) where {C<: AbstractRGB } = C (0 ,0 ,0 )
39+ zero (:: Type{C} ) where {C<: TransparentRGB } = C (0 ,0 ,0 ,0 )
40+ zero (p:: Colorant ) = zero (typeof (p))
41+ end
42+
43+ if ! hasmethod (one, (Gray{N0f8},))
44+ Base. one (:: Type{C} ) where {C<: AbstractGray } = C (1 )
45+ Base. one (:: Type{C} ) where {C<: TransparentGray } = C (1 ,1 )
46+ Base. one (:: Type{C} ) where {C<: AbstractRGB } = C (1 ,1 ,1 )
47+ Base. one (:: Type{C} ) where {C<: TransparentRGB } = C (1 ,1 ,1 ,1 )
48+ Base. one (p:: Colorant ) = one (typeof (p))
49+ end
50+
51+ if ! hasmethod (oneunit, (Type{AGray{N0f8}},))
52+ oneunit (:: Type{C} ) where {C<: TransparentGray } = C (1 ,1 )
53+ oneunit (:: Type{C} ) where {C<: AbstractRGB } = C (1 ,1 ,1 )
54+ oneunit (:: Type{C} ) where {C<: TransparentRGB } = C (1 ,1 ,1 ,1 )
55+ oneunit (p:: Colorant ) = oneunit (typeof (p))
56+ end
57+
3458# # Traits and key utilities
3559
3660# Return types for arithmetic operations
@@ -264,15 +288,15 @@ min(a::AbstractGray, b::Number) = min(promote(a,b)...)
264288atan (x:: AbstractGray , y:: AbstractGray ) = atan (gray (x), gray (y))
265289hypot (x:: AbstractGray , y:: AbstractGray ) = hypot (gray (x), gray (y))
266290
267- if ! hasmethod (< , Tuple{AbstractGray,AbstractGray}) # this was moved to ColorTypes 0.11
291+ if ! hasmethod (< , Tuple{AbstractGray,AbstractGray}) # planned for ColorTypes 0.11
268292 (< )(g1:: AbstractGray , g2:: AbstractGray ) = gray (g1) < gray (g2)
269293 (< )(c:: AbstractGray , r:: Real ) = gray (c) < r
270294 (< )(r:: Real , c:: AbstractGray ) = r < gray (c)
271295end
272296if ! hasmethod (isless, Tuple{AbstractGray,AbstractGray}) # this was moved to ColorTypes 0.10
273297 isless (g1:: AbstractGray , g2:: AbstractGray ) = isless (gray (g1), gray (g2))
274298end
275- if ! hasmethod (isless, Tuple{AbstractGray,Real}) # this was moved to ColorTypes 0.11
299+ if ! hasmethod (isless, Tuple{AbstractGray,Real}) # planned for ColorTypes 0.11
276300 isless (c:: AbstractGray , r:: Real ) = isless (gray (c), r)
277301 isless (r:: Real , c:: AbstractGray ) = isless (r, gray (c))
278302end
0 commit comments