@@ -31,6 +31,30 @@ export RGBRGB, nan, dotc, dot, ⋅, hadamard, ⊙, tensor, ⊗, norm, varmult
31
31
32
32
MathTypes{T,C} = Union{AbstractRGB{T},TransparentRGB{C,T},AbstractGray{T},TransparentGray{C,T}}
33
33
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
+
34
58
# # Traits and key utilities
35
59
36
60
# Return types for arithmetic operations
@@ -264,15 +288,15 @@ min(a::AbstractGray, b::Number) = min(promote(a,b)...)
264
288
atan (x:: AbstractGray , y:: AbstractGray ) = atan (gray (x), gray (y))
265
289
hypot (x:: AbstractGray , y:: AbstractGray ) = hypot (gray (x), gray (y))
266
290
267
- if ! hasmethod (< , Tuple{AbstractGray,AbstractGray}) # this was moved to ColorTypes 0.11
291
+ if ! hasmethod (< , Tuple{AbstractGray,AbstractGray}) # planned for ColorTypes 0.11
268
292
(< )(g1:: AbstractGray , g2:: AbstractGray ) = gray (g1) < gray (g2)
269
293
(< )(c:: AbstractGray , r:: Real ) = gray (c) < r
270
294
(< )(r:: Real , c:: AbstractGray ) = r < gray (c)
271
295
end
272
296
if ! hasmethod (isless, Tuple{AbstractGray,AbstractGray}) # this was moved to ColorTypes 0.10
273
297
isless (g1:: AbstractGray , g2:: AbstractGray ) = isless (gray (g1), gray (g2))
274
298
end
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
276
300
isless (c:: AbstractGray , r:: Real ) = isless (gray (c), r)
277
301
isless (r:: Real , c:: AbstractGray ) = isless (r, gray (c))
278
302
end
0 commit comments