Skip to content

Commit 7979a4d

Browse files
authored
Update to coloraide 5.1 and allow setting gamut map parameters in config (#278)
* Update to coloraide 5.1 and allow setting gamut map parameters in config * Upgrade ColorAide to 6.0.0 and require Python 3.13 for upcoming ST
1 parent dbe8ebd commit 7979a4d

File tree

146 files changed

+6986
-3044
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+6986
-3044
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- 'st3-*'
7+
- 'st4-*'
78

89
jobs:
910

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8
1+
3.13

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ColorHelper
22

3+
## 6.5.0
4+
5+
- **NEW**: Upgrade ColorAide to 6.0.0.
6+
- **NEW**: Allow setting gamut map parameters in settings file.
7+
- **NEW**: Require Python 3.13 for Sublim Text 4201+.
8+
39
## 6.4.5
410

511
- **FIX**: Fix SCSS support.

ch_mixin.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ def setup_gamut_style(self):
2323
ch_settings = sublime.load_settings('color_helper.sublime-settings')
2424
self.show_out_of_gamut_preview = ch_settings.get('show_out_of_gamut_preview', True)
2525
self.gamut_space = ch_settings.get('gamut_space', 'srgb')
26-
self.gamut_map = ch_settings.get('gamut_map', 'lch-chroma')
26+
gmap = ch_settings.get('gamut_map', {'method': 'minde-chroma', 'pspace': 'lch-d65'})
27+
if isinstance(gmap, str):
28+
gmap = {'method': gmap}
29+
self.gamut_map = gmap
2730
if self.gamut_space not in GAMUT_SPACES:
2831
self.gamut_space = 'srgb'
2932

@@ -35,7 +38,7 @@ def setup_image_border(self):
3538
if border_color is not None:
3639
try:
3740
border_color = self.base(border_color)
38-
border_color.fit(self.gamut_space, method=self.gamut_map)
41+
border_color.fit(self.gamut_space, **self.gamut_map)
3942
except Exception:
4043
border_color = None
4144

@@ -188,15 +191,15 @@ def get_preview(self, color):
188191
if not color.in_gamut(check_space):
189192
message = 'preview out of gamut'
190193
if self.show_out_of_gamut_preview:
191-
pcolor = color.convert(self.gamut_space, fit=self.gamut_map)
194+
pcolor = color.convert(self.gamut_space).fit(**self.gamut_map)
192195
preview1 = pcolor.clone().set('alpha', 1)
193196
preview2 = pcolor
194197
else:
195198
preview1 = self.out_of_gamut
196199
preview2 = self.out_of_gamut
197200
preview_border = self.out_of_gamut_border
198201
else:
199-
pcolor = color.convert(self.gamut_space, fit=self.gamut_map)
202+
pcolor = color.convert(self.gamut_space).fit(**self.gamut_map)
200203
preview1 = pcolor.clone().set('alpha', 1)
201204
preview2 = pcolor
202205

ch_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def color_picker(self, color):
245245

246246
if self.os_color_picker:
247247
self.view.hide_popup()
248-
new_color = native_picker(self.base(color).convert("srgb", fit=self.gamut_map))
248+
new_color = native_picker(self.base(color).convert("srgb").fit(**self.gamut_map))
249249
if new_color is not None:
250250
sublime.set_timeout(
251251
lambda c=new_color.to_string(**util.COLOR_FULL_PREC): self.view.run_command(

ch_picker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def setup(self, color, mode, controls, on_done, on_cancel):
6969
self.setup_controls(controls)
7070
color.convert(self.mode, in_place=True)
7171
if not color.in_gamut():
72-
color.fit(method=self.gamut_map)
72+
color.fit(**self.gamut_map)
7373
else:
7474
color.clip()
7575
# Ensure hue is between 0 - 360.

ch_preview.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ def setup_gamut_options(self):
271271

272272
self.show_out_of_gamut_preview = ch_settings.get('show_out_of_gamut_preview', True)
273273
self.gamut_space = ch_settings.get('gamut_space', 'srgb')
274-
self.gamut_map = ch_settings.get('gamut_map', 'lch-chroma')
274+
gmap = ch_settings.get('gamut_map', {'method': 'minde-chroma', 'pspace': 'lch-d65'})
275+
if isinstance(gmap, str):
276+
gmap = {'method': gmap}
277+
self.gamut_map = gmap
275278
if self.gamut_space not in util.GAMUT_SPACES:
276279
self.gamut_space = 'srgb'
277280
self.out_of_gamut = self.base("transparent").convert(self.gamut_space)
@@ -437,7 +440,7 @@ def do_search(self, force=False):
437440
mdpopups.scope2style(self.view, self.view.scope_name(pt))['background']
438441
).convert("hsl")
439442
hsl['lightness'] = hsl['lightness'] + (0.3 if hsl.luminance() < 0.5 else -0.3)
440-
preview_border = hsl.convert(self.gamut_space, fit=self.gamut_map).set('alpha', 1)
443+
preview_border = hsl.convert(self.gamut_space).fit(**self.gamut_map).set('alpha', 1)
441444

442445
color = self.base(obj.color)
443446
title = ''
@@ -448,15 +451,15 @@ def do_search(self, force=False):
448451
if not color.in_gamut(check_space):
449452
title = ' title="Preview out of gamut"'
450453
if self.show_out_of_gamut_preview:
451-
pcolor = color.convert(self.gamut_space, fit=self.gamut_map)
454+
pcolor = color.convert(self.gamut_space).fit(**self.gamut_map)
452455
preview1 = pcolor.clone().set('alpha', 1)
453456
preview2 = pcolor
454457
else:
455458
preview1 = self.out_of_gamut
456459
preview2 = self.out_of_gamut
457460
preview_border = self.out_of_gamut_border
458461
else:
459-
pcolor = color.convert(self.gamut_space, fit=self.gamut_map)
462+
pcolor = color.convert(self.gamut_space).fit(**self.gamut_map)
460463
preview1 = pcolor.clone().set('alpha', 1)
461464
preview2 = pcolor
462465

ch_tool_blend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ def preview(self, text):
185185
else:
186186
check_space = self.gamut_space
187187
if not pcolor.in_gamut(check_space):
188-
pcolor.fit(self.gamut_space, method=self.gamut_map)
188+
pcolor.fit(self.gamut_space, **self.gamut_map)
189189
message = '<br><em style="font-size: 0.9em;">* preview out of gamut</em>'
190190
color_string = "<strong>Gamut Mapped</strong>: {}<br>".format(pcolor.to_string())
191-
pcolor.convert(self.gamut_space, fit=self.gamut_map, in_place=True)
191+
pcolor.convert(self.gamut_space, in_place=True).fit(**self.gamut_map)
192192
color_string += "<strong>Color</strong>: {}".format(color.to_string(**util.DEFAULT))
193193
preview = pcolor.clone().set('alpha', 1)
194194
preview_alpha = pcolor

ch_tool_colormod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def preview(self, text):
106106
check_space = self.gamut_space
107107
if not pcolor.in_gamut(check_space):
108108
message = '<br><em style="font-size: 0.9em;">* preview out of gamut</em>'
109-
pcolor.convert(self.gamut_space, fit=self.gamut_map, in_place=True)
109+
pcolor.convert(self.gamut_space, in_place=True).fit(**self.gamut_map)
110110
preview = pcolor.clone().set('alpha', 1)
111111
preview_alpha = pcolor
112112
preview_border = self.default_border

ch_tool_contrast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ def evaluate(base, string, gamut_map):
114114

115115
# Package up the color, or the two reference colors along with the mixed.
116116
if first:
117-
colors.append(first.fit('srgb', method=gamut_map))
117+
colors.append(first.fit('srgb', **gamut_map))
118118
if second:
119119
if second[-1] < 1.0:
120120
second[-1] = 1.0
121-
colors.append(second.fit('srgb', method=gamut_map))
121+
colors.append(second.fit('srgb', **gamut_map))
122122
if ratio:
123123
if first[-1] < 1.0:
124124
first = first.compose(second, space="srgb", out_space=first.space())

0 commit comments

Comments
 (0)