1- from materialyoucolor .hct import Hct
21from materialyoucolor .hct .cam16 import Cam16
2+ from materialyoucolor .hct .hct import Hct
3+ from materialyoucolor .utils .color_utils import lstar_from_argb
34from materialyoucolor .utils .math_utils import (
4- sanitize_degrees_double ,
55 difference_degrees ,
66 rotation_direction ,
7+ sanitize_degrees_double ,
78)
8- from materialyoucolor .utils .color_utils import lstar_from_argb
99
1010
1111class Blend :
12+ """
13+ Functions for blending in HCT and CAM16.
14+ """
15+
1216 @staticmethod
1317 def harmonize (design_color : int , source_color : int ) -> int :
18+ """
19+ Blend the design color's HCT hue towards the key color's HCT
20+ hue, in a way that leaves the original color recognizable and
21+ recognizably shifted towards the key color.
22+ """
1423 from_hct = Hct .from_int (design_color )
1524 to_hct = Hct .from_int (source_color )
1625 difference_degrees_ = difference_degrees (from_hct .hue , to_hct .hue )
@@ -22,17 +31,24 @@ def harmonize(design_color: int, source_color: int) -> int:
2231 return Hct .from_hct (output_hue , from_hct .chroma , from_hct .tone ).to_int ()
2332
2433 @staticmethod
25- def hct_hue (from_ : int , to : int , amount : int ) -> int :
26- ucs = Blend .cam16_ucs (from_ , to , amount )
34+ def hct_hue (from_argb : int , to_argb : int , amount : float ) -> int :
35+ """
36+ Blends hue from one color into another. The chroma and tone of
37+ the original color are maintained.
38+ """
39+ ucs = Blend .cam16_ucs (from_argb , to_argb , amount )
2740 ucs_cam = Cam16 .from_int (ucs )
28- from_cam = Cam16 .from_int (from_ )
29- blended = Hct .from_hct (ucs_cam .hue , from_cam .chroma , lstar_from_argb (from_ ))
41+ from_cam = Cam16 .from_int (from_argb )
42+ blended = Hct .from_hct (ucs_cam .hue , from_cam .chroma , lstar_from_argb (from_argb ))
3043 return blended .to_int ()
3144
3245 @staticmethod
33- def cam16_ucs (from_ : int , to : int , amount : float ) -> int :
34- from_cam = Cam16 .from_int (from_ )
35- to_cam = Cam16 .from_int (to )
46+ def cam16_ucs (from_argb : int , to_argb : int , amount : float ) -> int :
47+ """
48+ Blend in CAM16-UCS space.
49+ """
50+ from_cam = Cam16 .from_int (from_argb )
51+ to_cam = Cam16 .from_int (to_argb )
3652 from_j = from_cam .jstar
3753 from_a = from_cam .astar
3854 from_b = from_cam .bstar
0 commit comments