Skip to content

Commit

Permalink
Merge branch 'upstream_master' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	tox.ini
  • Loading branch information
CodeByZach committed Jul 2, 2024
2 parents e53f036 + 5d44541 commit 365d066
Show file tree
Hide file tree
Showing 142 changed files with 4,075 additions and 3,262 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -59,7 +59,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
869 changes: 445 additions & 424 deletions CHANGES.md

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions ColorHelper.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"gamut_space": "srgb",

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

Expand All @@ -135,7 +135,6 @@
// "ColorHelper.lib.coloraide.spaces.acescc.ACEScc",
// "ColorHelper.lib.coloraide.spaces.acescg.ACEScg",
// "ColorHelper.lib.coloraide.spaces.acescct.ACEScct",
// "ColorHelper.lib.coloraide.spaces.cam16.CAM16",
// "ColorHelper.lib.coloraide.spaces.cam16_jmh.CAM16JMh",
// "ColorHelper.lib.coloraide.spaces.cam16_ucs.CAM16UCS",
// "ColorHelper.lib.coloraide.spaces.cam16_ucs.CAM16SCD",
Expand All @@ -149,7 +148,7 @@
// "ColorHelper.lib.coloraide.spaces.hunter_lab.HunterLab",
// "ColorHelper.lib.coloraide.spaces.ictcp.ICtCp",
// "ColorHelper.lib.coloraide.spaces.igtgpg.IgTgPg",
// "ColorHelper.lib.coloraide.spaces.itp.ITP",
// "ColorHelper.lib.coloraide.spaces.ipt.IPT",
// "ColorHelper.lib.coloraide.spaces.jzazbz.Jzazbz",
// "ColorHelper.lib.coloraide.spaces.jzczhz.JzCzhz",
// "ColorHelper.lib.coloraide.spaces.lch99o.LCh99o",
Expand All @@ -158,6 +157,7 @@
// "ColorHelper.lib.coloraide.spaces.rec2100_hlg.Rec2100HLG",
// "ColorHelper.lib.coloraide.spaces.rec2100_pq.Rec2100PQ",
// "ColorHelper.lib.coloraide.spaces.rlab.RLAB",
// "ColorHelper.lib.coloraide.spaces.ryb.RYB",
// "ColorHelper.lib.coloraide.spaces.xyb.XYB",
// "ColorHelper.lib.coloraide.spaces.xyy.xyY",
"ColorHelper.lib.coloraide.spaces.hsluv.HSLuv",
Expand Down Expand Up @@ -257,7 +257,8 @@
"output": [
{"space": "srgb", "format": {"hex": true}},
{"space": "srgb", "format": {"comma": true, "precision": 3}},
{"space": "hsl", "format": {"comma": true, "precision": 3}}
{"space": "hsl", "format": {"comma": true, "precision": 3}},
{"space": "hwb", "format": {"comma": true, "precision": 3}}
]
},
"tmtheme": {
Expand Down Expand Up @@ -501,7 +502,8 @@
"scanning": [
"constant.other.color.rgb-value.css",
"constant.color.w3c-standard-color-name.css",
"meta.property-value.css"
"meta.property-value.css",
"support.function.color.css"
]
},
{
Expand All @@ -511,6 +513,14 @@
"scanning": ["constant.other.color"],
"color_class": "ass_abgr",
"color_trigger": "(?:&H|(?<=\\\\[1-4]c)|(?<=\\\\c))[0-9a-fA-F]"
},
{
// INI (based on https://packagecontrol.io/packages/INI)
"name": "INI",
"syntax_files": ["INI/INI"],
"base_scopes": ["source.ini"],
"color_class": "css-level-4",
"scanning": ["meta.mapping.value.ini"]
}
],

Expand Down
10 changes: 5 additions & 5 deletions ch_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_color_map_square_hsv(self, mode='hsv'):
global default_border
global color_scale

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

r_sat = saturation
r_val = value
Expand Down Expand Up @@ -248,7 +248,7 @@ def get_color_map_square(self, mode='hsl'):
global default_border
global color_scale

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

r_sat = saturation
r_lit = lightness
Expand Down Expand Up @@ -502,7 +502,7 @@ def get_channel(self, channel, label, color_filter, mode='undefined'):
clone = self.color.clone()
show_alpha = color_filter == 'alpha'

coord = alg.no_nan(clone[color_filter])
coord = clone.get(color_filter, nans=False)
if color_filter != 'hue':
rounded = alg.round_half_up(coord, 2 if mode != 'hsluv' else 0)
clone[color_filter] = rounded
Expand All @@ -514,7 +514,7 @@ def get_channel(self, channel, label, color_filter, mode='undefined'):

first = True
while count:
coord = alg.no_nan(clone[color_filter]) - step
coord = clone.get(color_filter, nans=False) - step
clone[color_filter] = coord

if color_filter != "hue" and (coord < 0 or coord > (1 * scale)):
Expand Down Expand Up @@ -564,7 +564,7 @@ def get_channel(self, channel, label, color_filter, mode='undefined'):
clone.update(self.color)
clone[color_filter] = rounded
while count:
coord = alg.no_nan(clone[color_filter]) + step
coord = clone.get(color_filter, nans=False) + step
clone[color_filter] = coord

if color_filter != "hue" and (coord < 0 or coord > (1 * scale)):
Expand Down
6 changes: 2 additions & 4 deletions custom/ahex.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ class ASRGB(sRGB):

COLOR_FORMAT = False

@classmethod
def match(cls, string, start=0, fullmatch=True):
def match(self, string, start=0, fullmatch=True):
"""Match a CSS color string."""

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

@classmethod
def to_string(
cls, parent, *, options=None, alpha=None, precision=None, fit=True, none=False, **kwargs
self, parent, *, options=None, alpha=None, precision=None, fit=True, none=False, **kwargs
):
"""Convert to Hex format."""

Expand Down
6 changes: 2 additions & 4 deletions custom/ass_abgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ def split_channels(color: str):
class AssABGR(sRGB):
"""ASS `ABGR` color space."""

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

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

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

options = kwargs
Expand Down
8 changes: 3 additions & 5 deletions custom/hex_0x.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Custon color that looks for colors of format `#RRGGBBAA` as `#AARRGGBB`."""
"""Custom color that looks for colors of format `#RRGGBBAA` as `#AARRGGBB`."""
from ..lib.coloraide.spaces.srgb.css import sRGB
from ..lib.coloraide.css import parse, serialize
import re
Expand All @@ -10,18 +10,16 @@
class HexSRGB(sRGB):
"""SRGB that looks for alpha first in hex format."""

@classmethod
def match(cls, string, start=0, fullmatch=True):
def match(self, string, start=0, fullmatch=True):
"""Match a CSS color string."""

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

@classmethod
def to_string(
cls, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
self, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
):
"""Convert to CSS."""

Expand Down
14 changes: 8 additions & 6 deletions custom/st_colormod.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,35 @@ def handle_vars(string, variables, parents=None):
class HWB(HWBORIG):
"""HWB class that allows commas."""

@classmethod
def match(cls, string, start=0, fullmatch=True):
def match(self, string, start=0, fullmatch=True):
"""Match a CSS color string."""

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

@classmethod
def to_string(
cls,
self,
parent,
*,
alpha=None,
precision=None,
percent: bool = True,
percent=None,
fit=True,
none=False,
color: bool = False,
comma: bool = False,
**kwargs
) -> str:
"""Convert to CSS."""

if percent is None:
percent = False if color else True

return serialize.serialize_css(
parent,
func='hwb',
Expand Down
6 changes: 2 additions & 4 deletions custom/tmtheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,8 @@ def name2hex(name):
class SRGBX11(sRGB):
"""sRGB class."""

@classmethod
def to_string(
cls, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
self, parent, *, alpha=None, precision=None, fit=True, none=False, **kwargs
):
"""Convert to CSS."""

Expand Down Expand Up @@ -727,8 +726,7 @@ def to_string(

return value

@classmethod
def match(cls, string, start=0, fullmatch=True):
def match(self, string, start=0, fullmatch=True):
"""Match a CSS color string."""

m = MATCH.match(string, start)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/markdown/settings/previews.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ else in the code.
```js
// Gamut mapping approach
// Supported methods are: `lch-chroma`, `oklch-chroma`, and `clip` (default).
// Supported methods are: `lch-chroma`, `oklch-chroma`, `oklch-raytrace`, and `clip` (default).
// `lch-chroma` was the original default before this was configurable.
"gamut_map": "clip",
```
Expand Down
5 changes: 3 additions & 2 deletions lib/coloraide/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Meta related things."""
from __future__ import annotations
from collections import namedtuple
import re

Expand Down Expand Up @@ -83,7 +84,7 @@ def __new__(
cls,
major: int, minor: int, micro: int, release: str = "final",
pre: int = 0, post: int = 0, dev: int = 0
) -> "Version":
) -> Version:
"""Validate version info."""

# Ensure all parts are positive integers.
Expand Down Expand Up @@ -192,5 +193,5 @@ def parse_version(ver: str) -> Version:
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(2, 9, 1, "final", post=1)
__version_info__ = Version(3, 3, 1, "final")
__version__ = __version_info__._get_canonical()
Loading

0 comments on commit 365d066

Please sign in to comment.