1
1
2
2
mapch (f, x, y) = mapc (f, x, y)
3
3
mapch (f, x:: C , y:: C ) where C <: Union{HSV, HSL, HSI} =
4
- C (f (Hue (x. h ), Hue (y. h )), f (x. s, y. s), f (comp3 (x), comp3 (y)))
4
+ C (f (Hue (x), Hue (y)), f (x. s, y. s), f (comp3 (x), comp3 (y)))
5
5
mapch (f, x:: C , y:: C ) where C <: Union{LCHab, LCHuv} =
6
- C (f (x. l, y. l), f (x. c, y. c), f (Hue (x. h ), Hue (y. h )))
6
+ C (f (x. l, y. l), f (x. c, y. c), f (Hue (x), Hue (y)))
7
7
8
8
mapca (fc, a, x:: C ) where C <: TransparentColorN{2} = C (fc (comp1 (x)), a)
9
9
mapca (fc, a, x:: C ) where C <: TransparentColorN{3} = C (fc (comp1 (x)), fc (comp2 (x)), a)
@@ -15,9 +15,9 @@ mapca(fc, a, x::C, y::C) where C <: TransparentColorN{3} =
15
15
mapca (fc, a, x:: C , y:: C ) where C <: TransparentColorN{4} =
16
16
C (fc (comp1 (x), comp1 (y)), fc (comp2 (x), comp2 (y)), fc (comp3 (x), comp3 (y)), a)
17
17
mapca (fc, a, x:: C , y:: C ) where C <: TransparentColorN{4, <:Union{HSV, HSL, HSI}} =
18
- C (fc (Hue (x. h ), Hue (y. h )), fc (x. s, y. s), fc (comp3 (x), comp3 (y)), a)
18
+ C (fc (Hue (x), Hue (y)), fc (x. s, y. s), fc (comp3 (x), comp3 (y)), a)
19
19
mapca (fc, a, x:: C , y:: C ) where C <: TransparentColorN{4, <:Union{LCHab, LCHuv}} =
20
- C (fc (x. l, y. l), fc (x. c, y. c), fc (Hue (x. h ), Hue (y. h )))
20
+ C (fc (x. l, y. l), fc (x. c, y. c), fc (Hue (x), Hue (y)))
21
21
22
22
# complement
23
23
_n (v:: T ) where T = oneunit (T) - v
@@ -26,9 +26,11 @@ _n(v::T) where T = oneunit(T) - v
26
26
_w (v1:: T , v2:: T , w) where T = convert (T, muladd (_n (w), v1, w * v2))
27
27
28
28
function _w (h1:: Hue{T} , h2:: Hue{T} , w) where T
29
- d0 = h2. angle - h1. angle
29
+ h1a = ifelse (h1. isgray, h2. angle, h1. angle)
30
+ h2a = ifelse (h2. isgray, h1. angle, h2. angle)
31
+ d0 = h2a - h1a
30
32
d = ifelse (abs (d0) > T (180 ), d0 - copysign (T (360 ), d0), d0)
31
- a = muladd (d, w, h1 . angle )
33
+ a = muladd (d, w, h1a )
32
34
convert (T, ifelse (a > T (360 ), a - T (360 ), ifelse (a < T (0 ), a + T (360 ), a)))
33
35
end
34
36
@@ -45,8 +47,7 @@ _w_safe(v1::T, w1, v2::T, w2) where T = min(oneunit(T), _w(v1, w1, v2, w2))
45
47
_w_safe (v1:: T , w1, v2:: T , w2) where T <: FixedPoint =
46
48
convert (T, min (float (typemax (T)), muladd (w1, float (v1), w2 * float (v2))))
47
49
48
- _comp (op:: CompositeOperation{:clear} , c1, c2) =
49
- mapc (v1 -> zero (v1), c1)
50
+ _comp (op:: CompositeOperation{:clear} , c1, c2) = mapc (v1 -> zero (v1), c1)
50
51
51
52
_comp (op:: CompositeOperation{:copy} , c1, c2) = c2
52
53
0 commit comments