@@ -95,6 +95,8 @@ shift in blue.
9595
9696``` py play
9797import math
98+ from coloraide import stop
99+
98100
99101def prepare_msh_divergent_interpolation (c1 , c2 ):
100102 """ Optimize colors for interpolation."""
@@ -140,13 +142,17 @@ def prepare_msh_divergent_interpolation(c1, c2):
140142 colors.append(c2)
141143
142144 # Adjust hue of unsaturated colors.
143- if (colors[1 ][' s' ] < 0.05 ) and (colors[0 ][' s' ] > 0.05 ):
145+ if (colors[0 ][' s' ] < 0.05 ) and (colors[1 ][' s' ] > 0.05 ):
146+ colors[0 ][' h' ] = adjust_hue(colors[1 ].coords(), colors[0 ][' m' ])
147+ elif (colors[1 ][' s' ] < 0.05 ) and (colors[0 ][' s' ] > 0.05 ):
144148 colors[1 ][' h' ] = adjust_hue(colors[0 ].coords(), colors[1 ][' m' ])
145- elif (colors[- 2 ][' s' ] < 0.05 ) and (colors[- 1 ][' s' ] > 0.05 ):
146- colors[- 2 ][' h' ] = adjust_hue(colors[- 1 ].coords(), colors[- 2 ][' m' ])
147149
148150 # If white was inserted, adjust hues of unsaturated color on the right side.
149151 if len (colors) > 2 :
152+ if (colors[- 2 ][' s' ] < 0.05 ) and (colors[- 1 ][' s' ] > 0.05 ):
153+ colors[- 2 ][' h' ] = adjust_hue(colors[- 1 ].coords(), colors[- 2 ][' m' ])
154+ elif (colors[- 1 ][' s' ] < 0.05 ) and (colors[- 2 ][' s' ] > 0.05 ):
155+ colors[- 1 ][' h' ] = adjust_hue(colors[- 2 ].coords(), colors[- 1 ][' m' ])
150156 colors[1 ] = stop(colors[1 ], 0.5 )
151157 colors[- 2 ] = stop(colors[- 2 ], 0.5 )
152158
0 commit comments