@@ -26,16 +26,12 @@ import LinearAlgebra: norm, ⋅, dot, promote_leaf_eltypes # norm1, norm2, norm
2626using Statistics
2727import Statistics: middle # and `_mean_promote`
2828
29+ isdefined (Base, :get_extension ) || using Requires
30+
2931export RGBRGB, complement, nan, dotc, dot, ⋅ , hadamard, ⊙ , tensor, ⊗ , norm, varmult, stdmult
3032
3133MathTypes{T,C<: Union{AbstractGray{T},AbstractRGB{T}} } = Union{C,TransparentColor{C,T}}
3234
33- if Base. VERSION >= v " 1.5"
34- @inline _depwarn (msg, funcsym; force= false ) = Base. depwarn (msg, funcsym; force= force)
35- else
36- @inline _depwarn (msg, funcsym; force= false ) = Base. depwarn (msg, funcsym)
37- end
38-
3935# # Version compatibility with ColorTypes
4036# ## TODO : Remove the definitons other than `one` when dropping ColorTypes v0.10 support
4137
@@ -479,40 +475,32 @@ end
479475Base. length (r:: StepRange{<:AbstractGray,<:AbstractGray} ) = length (StepRange (gray (r. start), gray (r. step), gray (r. stop)))
480476Base. length (r:: StepRange{<:AbstractGray} ) = length (StepRange (gray (r. start), r. step, gray (r. stop)))
481477
482- Base. abs2 (g:: AbstractGray ) = abs2 (gray (g))
483- function Base. abs2 (c:: AbstractRGB )
484- _depwarn ("""
485- The return value of `abs2` will change to ensure that `abs2(g::Gray) ≈ abs2(RGB(g::Gray))`.
486- For `RGB` colors, this results in dividing the previous output by 3.
487-
488- To avoid this warning, use `ColorVectorSpace.Future.abs2` instead of `abs2`; currently,
489- `abs2` returns the old value (for compatibility), and `ColorVectorSpace.Future.abs2` returns the new value.
490- When making this change, you may also need to adjust constants like color-difference thresholds
491- to compensate for the change in the returned value.
492-
493- If you are getting this from `var`, use `varmult` instead.
494- """ , :abs2 )
495- return mapreducec (v-> float (v)^ 2 , + , zero (eltype (c)), c)
496- end
478+ Base. abs2 (c:: Union{AbstractGray,AbstractRGB} ) = c ⋅ c
497479
498480module Future
499- using .. ColorTypes
500- using .. ColorVectorSpace: ⋅ , dot
501- """
502- ColorVectorSpace.Future.abs2(c)
503-
504- Return a scalar "squared magnitude" for color types. For RGB and gray, this is just the mean-square
505- channelwise intensity.
481+ using .. ColorTypes
482+ using .. ColorVectorSpace: ⋅
483+ """
484+ ColorVectorSpace.Future.abs2(c)
485+ Return a scalar "squared magnitude" for color types. For RGB and gray, this is just the mean-square
486+ channelwise intensity.
487+ """
488+
489+ if VERSION >= v " 1.5"
490+ @inline _depwarn (msg, funcsym; force= false ) = Base. depwarn (msg, funcsym; force= force)
491+ else
492+ @inline _depwarn (msg, funcsym; force= false ) = Base. depwarn (msg, funcsym)
493+ end
506494
507- Compatibility note: this gives a different result from `Base.abs2(c)`, but eventually `Base.abs2` will switch
508- to the definition used here. Using `ColorVectorSpace.Future.abs2` thus future-proofs your code.
509- For more information about the transition, see ColorVectorSpace's README.
510- """
511- abs2 (c:: Union{Real,AbstractGray,AbstractRGB} ) = c ⋅ c
495+ function abs2 (c:: Union{Real,AbstractGray,AbstractRGB} )
496+ _depwarn ("""
497+ The return value of `abs2` is now consistent with `ColorVectorSpace.Future.abs2`.
498+ `ColorVectorSpace.Future.abs2` will be removed in the future, please switch to `abs2`.""" , :abs2
499+ )
500+ c ⋅ c
501+ end
512502end
513503
514- isdefined (Base, :get_extension ) || using Requires
515-
516504function __init__ ()
517505 if isdefined (Base, :Experimental ) && isdefined (Base. Experimental, :register_error_hint )
518506 Base. Experimental. register_error_hint (MethodError) do io, exc, argtypes, kwargs
0 commit comments