Skip to content

Commit 4e86272

Browse files
authored
Upgrade coloraide (#267)
* Upgrade coloraide * Upgrade to latest coloraide * Update build configs * Fix lint issues * make note of new gamut map method * Update color space list in settings
1 parent 1242ab5 commit 4e86272

File tree

137 files changed

+3594
-2848
lines changed

Some content is hidden

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

137 files changed

+3594
-2848
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
2323
- name: Set up Python
2424
uses: actions/setup-python@v4
2525
with:
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040

4141
steps:
42-
- uses: actions/checkout@v3
42+
- uses: actions/checkout@v4
4343
- name: Set up Python
4444
uses: actions/setup-python@v4
4545
with:
@@ -59,7 +59,7 @@ jobs:
5959
runs-on: ubuntu-latest
6060

6161
steps:
62-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6363
- name: Set up Python
6464
uses: actions/setup-python@v4
6565
with:

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
with:
1717
fetch-depth: 0
1818
- name: Set up Python

CHANGES.md

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

3+
## 6.4
4+
5+
- **NEW**: Upgrade ColorAide.
6+
- **NEW**: Note in documentation and settings a new gamut mapping
7+
method, `oklch-raytrace`, which does a chroma reduction much
8+
faster and closer than the current suggested CSS algorithm.
9+
310
## 6.3.2
411

512
- **FIX**: Fix missing requirement for `math.isclose` in ColorAide

ch_picker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_color_map_square_hsv(self, mode='hsv'):
109109
global default_border
110110
global color_scale
111111

112-
hue, saturation, value = alg.no_nans(self.color.convert(mode)[:-1])
112+
hue, saturation, value = self.color.convert(mode).coords(nans=False)
113113

114114
r_sat = saturation
115115
r_val = value
@@ -248,7 +248,7 @@ def get_color_map_square(self, mode='hsl'):
248248
global default_border
249249
global color_scale
250250

251-
hue, saturation, lightness = alg.no_nans(self.color.convert(mode)[:-1])
251+
hue, saturation, lightness = self.color.convert(mode).coords(nans=False)
252252

253253
r_sat = saturation
254254
r_lit = lightness

color_helper.sublime-settings

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"gamut_space": "srgb",
118118

119119
// Gamut mapping approach
120-
// Supported methods are: `lch-chroma`, `oklch-chroma`, and `clip` (default).
120+
// Supported methods are: `lch-chroma`, `oklch-chroma`, `oklch-raytrace`, and `clip` (default).
121121
// `lch-chroma` was the original default before this was configurable.
122122
"gamut_map": "clip",
123123

@@ -135,7 +135,6 @@
135135
// "ColorHelper.lib.coloraide.spaces.acescc.ACEScc",
136136
// "ColorHelper.lib.coloraide.spaces.acescg.ACEScg",
137137
// "ColorHelper.lib.coloraide.spaces.acescct.ACEScct",
138-
// "ColorHelper.lib.coloraide.spaces.cam16.CAM16",
139138
// "ColorHelper.lib.coloraide.spaces.cam16_jmh.CAM16JMh",
140139
// "ColorHelper.lib.coloraide.spaces.cam16_ucs.CAM16UCS",
141140
// "ColorHelper.lib.coloraide.spaces.cam16_ucs.CAM16SCD",
@@ -149,7 +148,7 @@
149148
// "ColorHelper.lib.coloraide.spaces.hunter_lab.HunterLab",
150149
// "ColorHelper.lib.coloraide.spaces.ictcp.ICtCp",
151150
// "ColorHelper.lib.coloraide.spaces.igtgpg.IgTgPg",
152-
// "ColorHelper.lib.coloraide.spaces.itp.ITP",
151+
// "ColorHelper.lib.coloraide.spaces.ipt.IPT",
153152
// "ColorHelper.lib.coloraide.spaces.jzazbz.Jzazbz",
154153
// "ColorHelper.lib.coloraide.spaces.jzczhz.JzCzhz",
155154
// "ColorHelper.lib.coloraide.spaces.lch99o.LCh99o",
@@ -158,6 +157,7 @@
158157
// "ColorHelper.lib.coloraide.spaces.rec2100_hlg.Rec2100HLG",
159158
// "ColorHelper.lib.coloraide.spaces.rec2100_pq.Rec2100PQ",
160159
// "ColorHelper.lib.coloraide.spaces.rlab.RLAB",
160+
// "ColorHelper.lib.coloraide.spaces.ryb.RYB",
161161
// "ColorHelper.lib.coloraide.spaces.xyb.XYB",
162162
// "ColorHelper.lib.coloraide.spaces.xyy.xyY",
163163
"ColorHelper.lib.coloraide.spaces.hsluv.HSLuv",
@@ -257,7 +257,8 @@
257257
"output": [
258258
{"space": "srgb", "format": {"hex": true}},
259259
{"space": "srgb", "format": {"comma": true, "precision": 3}},
260-
{"space": "hsl", "format": {"comma": true, "precision": 3}}
260+
{"space": "hsl", "format": {"comma": true, "precision": 3}},
261+
{"space": "hwb", "format": {"comma": true, "precision": 3}}
261262
]
262263
},
263264
"tmtheme": {

custom/ahex.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ class ASRGB(sRGB):
3636

3737
COLOR_FORMAT = False
3838

39-
@classmethod
40-
def match(cls, string, start=0, fullmatch=True):
39+
def match(self, string, start=0, fullmatch=True):
4140
"""Match a CSS color string."""
4241

4342
m = MATCH.match(string, start)
4443
if m is not None and (not fullmatch or m.end(0) == len(string)):
4544
return split_channels(m.group(0)), m.end(0)
4645
return None
4746

48-
@classmethod
4947
def to_string(
50-
cls, parent, *, options=None, alpha=None, precision=None, fit=True, none=False, **kwargs
48+
self, parent, *, options=None, alpha=None, precision=None, fit=True, none=False, **kwargs
5149
):
5250
"""Convert to Hex format."""
5351

custom/ass_abgr.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ def split_channels(color: str):
3232
class AssABGR(sRGB):
3333
"""ASS `ABGR` color space."""
3434

35-
@classmethod
36-
def match(cls, string: str, start: int = 0, fullmatch: bool = True):
35+
def match(self, string: str, start: int = 0, fullmatch: bool = True):
3736
"""Match a color string."""
3837

3938
m = MATCH.match(string, start)
4039
if m is not None and (not fullmatch or m.end(0) == len(string)):
4140
return split_channels(m.group("color")), m.end(0)
4241
return None
4342

44-
@classmethod
45-
def to_string(cls, parent, *, options=None, alpha=None, precision=None, fit=True, none=False, **kwargs):
43+
def to_string(self, parent, *, options=None, alpha=None, precision=None, fit=True, none=False, **kwargs):
4644
"""Convert color to `&HAABBGGRR`."""
4745

4846
options = kwargs

custom/hex_0x.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Custon color that looks for colors of format `#RRGGBBAA` as `#AARRGGBB`."""
1+
"""Custom color that looks for colors of format `#RRGGBBAA` as `#AARRGGBB`."""
22
from ..lib.coloraide.spaces.srgb.css import sRGB
33
from ..lib.coloraide.css import parse, serialize
44
import re
@@ -10,18 +10,16 @@
1010
class HexSRGB(sRGB):
1111
"""SRGB that looks for alpha first in hex format."""
1212

13-
@classmethod
14-
def match(cls, string, start=0, fullmatch=True):
13+
def match(self, string, start=0, fullmatch=True):
1514
"""Match a CSS color string."""
1615

1716
m = MATCH.match(string, start)
1817
if m is not None and (not fullmatch or m.end(0) == len(string)):
1918
return parse.parse_hex(m.group(0).replace('0x', '#', 1)), m.end(0)
2019
return None
2120

22-
@classmethod
2321
def to_string(
24-
cls, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
22+
self, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
2523
):
2624
"""Convert to CSS."""
2725

custom/st_colormod.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,33 +184,35 @@ def handle_vars(string, variables, parents=None):
184184
class HWB(HWBORIG):
185185
"""HWB class that allows commas."""
186186

187-
@classmethod
188-
def match(cls, string, start=0, fullmatch=True):
187+
def match(self, string, start=0, fullmatch=True):
189188
"""Match a CSS color string."""
190189

191190
m = HWB_MATCH.match(string, start)
192191
if m is not None and (not fullmatch or m.end(0) == len(string)):
193192
return parse.parse_channels(
194193
list(RE_CHAN_VALUE.findall(string[m.end(1) + 1:m.end(0) - 1])),
195-
cls.CHANNELS, scaled=True
194+
self.CHANNELS, scaled=True
196195
), m.end(0)
197196
return None
198197

199-
@classmethod
200198
def to_string(
201-
cls,
199+
self,
202200
parent,
203201
*,
204202
alpha=None,
205203
precision=None,
206-
percent: bool = True,
204+
percent=None,
207205
fit=True,
208206
none=False,
207+
color: bool = False,
209208
comma: bool = False,
210209
**kwargs
211210
) -> str:
212211
"""Convert to CSS."""
213212

213+
if percent is None:
214+
percent = False if color else True
215+
214216
return serialize.serialize_css(
215217
parent,
216218
func='hwb',

custom/tmtheme.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,8 @@ def name2hex(name):
695695
class SRGBX11(sRGB):
696696
"""sRGB class."""
697697

698-
@classmethod
699698
def to_string(
700-
cls, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
699+
self, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
701700
):
702701
"""Convert to CSS."""
703702

@@ -727,8 +726,7 @@ def to_string(
727726

728727
return value
729728

730-
@classmethod
731-
def match(cls, string, start=0, fullmatch=True):
729+
def match(self, string, start=0, fullmatch=True):
732730
"""Match a CSS color string."""
733731

734732
m = MATCH.match(string, start)

0 commit comments

Comments
 (0)