@@ -395,14 +395,17 @@ When the hue difference is exactly 180 degrees, which of the two mean hues is
395
395
returned depends on the implementation. In other words, it may vary by the color
396
396
type and version.
397
397
"""
398
- function mean_hue (h1:: T , h2:: T ) where {T <: Real }
398
+ mean_hue (a, b) = _mean_hue (promote (a, b)... )
399
+
400
+ _mean_hue (a, b) = error (" input arguments to `mean_hue` could not promote to valid input types" )
401
+ function _mean_hue (h1:: T , h2:: T ) where {T <: Real }
399
402
@fastmath hmin, hmax = minmax (h1, h2)
400
403
d = 180 - normalize_hue (hmin - hmax - 180 )
401
404
F = typeof (zero (T) / 2 )
402
405
mh = muladd (F (0.5 ), d, hmin)
403
406
return mh < 0 ? mh + 360 : mh
404
407
end
405
- @inline function mean_hue (a:: C , b:: C ) where {Cb <: Union{Lab, Luv, Oklab} ,
408
+ @inline function _mean_hue (a:: C , b:: C ) where {Cb <: Union{Lab, Luv, Oklab} ,
406
409
C <: Union{Cb, AlphaColor{Cb}, ColorAlpha{Cb}} }
407
410
a1, b1, a2, b2 = comp2 (a), comp3 (a), comp2 (b), comp3 (b)
408
411
c1, c2 = chroma (a), chroma (b)
@@ -422,15 +425,14 @@ end
422
425
mb = muladd (k2, b1, k1 * b2)
423
426
hue (Cb (zero (ma), ma, mb))
424
427
end
425
- function mean_hue (a:: C , b:: C ) where {Cb <: Union{LCHab, LCHuv, Oklch} ,
428
+ function _mean_hue (a:: C , b:: C ) where {Cb <: Union{LCHab, LCHuv, Oklch} ,
426
429
C <: Union{Cb, AlphaColor{Cb}, ColorAlpha{Cb}} }
427
- mean_hue (a. c == 0 ? b. h : a. h, b. c == 0 ? a. h : b. h)
430
+ _mean_hue (a. c == 0 ? b. h : a. h, b. c == 0 ? a. h : b. h)
428
431
end
429
- function mean_hue (a:: C , b:: C ) where {Cb <: Union{HSV, HSL, HSI} ,
432
+ function _mean_hue (a:: C , b:: C ) where {Cb <: Union{HSV, HSL, HSI} ,
430
433
C <: Union{Cb, AlphaColor{Cb}, ColorAlpha{Cb}} }
431
- mean_hue (a. s == 0 ? b. h : a. h, b. s == 0 ? a. h : b. h)
434
+ _mean_hue (a. s == 0 ? b. h : a. h, b. s == 0 ? a. h : b. h)
432
435
end
433
- mean_hue (a, b) = mean_hue (promote (a, b)... )
434
436
435
437
_delta_h_th (T) = zero (T)
436
438
_delta_h_th (:: Type{Float32} ) = 0.1f0
0 commit comments