Skip to content

Commit bb4f67c

Browse files
committed
Fixes for latest ColorAide update
1 parent 7979a4d commit bb4f67c

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

CHANGES.md

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

3+
## 6.5.1
4+
5+
- **NEW**: Fix issues related to ColorAide update.
6+
37
## 6.5.0
48

59
- **NEW**: Upgrade ColorAide to 6.0.0.

custom/ahex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from ..lib.coloraide.css import parse
44
from ..lib.coloraide import algebra as alg
55
import re
6-
from ColorHelper.ch_util import get_base_color
6+
from ColorHelper.ch_util import get_base_color, COLOR_PARTS
77

8-
MATCH = re.compile(r"(?i)\#(?:{hex}{{8}}|{hex}{{6}})\b".format(**parse.COLOR_PARTS))
8+
MATCH = re.compile(r"(?i)\#(?:{hex}{{8}}|{hex}{{6}})\b".format(**COLOR_PARTS))
99

1010

1111
def split_channels(color):

custom/st_colormod.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ def _adjust(self, string, start=0):
290290
if color is None:
291291
m = RE_COLOR_START.match(string, start)
292292
if m:
293+
fullmatch = self.fullmatch
294+
self.fullmatch = False
293295
color2, start = self._adjust(string, start=start)
296+
self.fullmatch = fullmatch
294297
if color2 is None:
295298
raise ValueError("Found unterminated or invalid 'color('")
296299
color = color2.convert("srgb")
@@ -635,19 +638,20 @@ def _parse(
635638
num_data = len(data)
636639
if num_data < num_channels:
637640
data = list(data) + [alg.NaN] * (num_channels - num_data)
638-
coords = [alg.clamp(float(v), *c.limit) for c, v in zipl(space_class.CHANNELS, data)]
639-
coords.append(alg.clamp(float(alpha), *space_class.channels[-1].limit))
641+
coords = [float(c.limit(v) if c.limit is not None else v) for c, v in zipl(space_class.CHANNELS, data)]
642+
limit = space_class.channels[-1].limit
643+
coords.append(float(limit(alpha) if limit is not None else alpha))
640644
obj = space_class, coords
641645

642646
# Parse a CSS string
643647
else:
644648
m = cls._match(color, fullmatch=True, variables=variables)
645649
if m is None:
646650
raise ValueError("'{}' is not a valid color".format(color))
647-
coords = [alg.clamp(float(v), *c.limit) for c, v in zipl(m[0].CHANNELS, m[1])]
648-
coords.append(alg.clamp(float(m[2]), *m[0].channels[-1].limit))
651+
coords = [float(c.limit(v) if c.limit is not None else v) for c, v in zipl(m[0].CHANNELS, m[1])]
652+
limit = m[0].channels[-1].limit
653+
coords.append(float(limit(m[2]) if limit is not None else m[2]))
649654
obj = m[0], coords
650-
651655
# Handle a color instance
652656
elif isinstance(color, BASE):
653657
space_class = cls.CS_MAP.get(color.space())

support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import webbrowser
66
import re
77

8-
__version__ = "6.5.0"
8+
__version__ = "6.5.1"
99
__pc_name__ = 'ColorHelper'
1010

1111
CSS = '''

0 commit comments

Comments
 (0)