Skip to content

Commit 9e15cc5

Browse files
committed
Consistent naming and fix plot scripts
1 parent fa4fb46 commit 9e15cc5

5 files changed

Lines changed: 26 additions & 22 deletions

File tree

coloraide/channels.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Channel(str):
3333
flags: int
3434
limit: Callable[[float], float | int]
3535
nans: float
36-
hue: int
36+
angle: int
3737

3838
def __new__(
3939
cls,
@@ -51,10 +51,10 @@ def __new__(
5151
obj = super().__new__(cls, name)
5252
obj.bound = bound
5353
obj.flags = flags
54-
obj.hue = (ANGLE_DEG if angle == ANGLE_NULL else angle) if flags & FLG_ANGLE else ANGLE_NULL
55-
if obj.hue:
56-
obj.low = ANGLE_RANGE[obj.hue][0]
57-
obj.high = ANGLE_RANGE[obj.hue][1]
54+
obj.angle = (ANGLE_DEG if angle == ANGLE_NULL else angle) if flags & FLG_ANGLE else ANGLE_NULL
55+
if obj.angle:
56+
obj.low = ANGLE_RANGE[obj.angle][0]
57+
obj.high = ANGLE_RANGE[obj.angle][1]
5858
else:
5959
obj.low = low
6060
obj.high = high

coloraide/color.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def __repr__(self) -> str:
710710
self._space._serialize()[0],
711711
' '.join(
712712
[
713-
util.fmt_float(self[i], util.DEF_PREC, util.DEF_ROUND_MODE) + POSTFIX[channels[i].hue]
713+
util.fmt_float(self[i], util.DEF_PREC, util.DEF_ROUND_MODE) + POSTFIX[channels[i].angle]
714714
for i in range(l - 1)
715715
]
716716
),

coloraide/css/parse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def parse_channels(color: list[str], boundry: tuple[Channel, ...], scaled: bool
164164
bound = boundry[i]
165165
if bound.flags & FLG_ANGLE:
166166
v = norm_angle_channel(c)
167-
channels.append(v * (bound.high / 360) if bound.hue != ANGLE_DEG else v)
167+
channels.append(v * (bound.high / 360) if bound.angle != ANGLE_DEG else v)
168168
elif scaled:
169169
channels.append(norm_scaled_color_channel(c, bound.high))
170170
else:
@@ -196,7 +196,7 @@ def parse_color(tokens: dict[str, Any], space: Space) -> tuple[Vector, float] |
196196
channel = properties[i]
197197
if channel.flags & FLG_ANGLE:
198198
v = norm_angle_channel(c)
199-
channels.append(v * (channel.high / 360) if channel.hue != ANGLE_DEG else v)
199+
channels.append(v * (channel.high / 360) if channel.angle != ANGLE_DEG else v)
200200
else:
201201
channels.append(norm_color_channel(c.lower(), channel.span, channel.offset))
202202
return (channels, alpha)

docs/src/markdown/examples/3d_models.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ <h1>ColorAide Color Space Models</h1>
226226
from coloraide.channels import ANGLE_DEG
227227
from coloraide.spaces import HSLish, HSVish, HWBish, Labish, LChish, RGBish
228228
from coloraide import algebra as alg
229-
from coloraide.css.serialize import POSTFIX
229+
from coloraide.color import POSTFIX
230230

231231
FORCE_OWN_GAMUT = {'ryb', 'ryb-biased'}
232232

@@ -638,16 +638,18 @@ <h1>ColorAide Color Space Models</h1>
638638
"gridcolor": gridcolor,
639639
"zerolinecolor": zerolinecolor,
640640
}
641-
min_hue = target.channels[target.hue_index()].low
642-
max_hue = target.channels[target.hue_index()].high
643-
type_hue = target.channels[target.hue_index()].hue
644641

645642
if not is_cyl:
646643
xaxis = str(names[axm[0]])
647-
elif max_hue == 360:
648-
xaxis = f"{names[axm[0]]} (0˚ - 360˚)"
649644
else:
650-
xaxis = f"{names[axm[0]]} ({min_hue}{POSTFIX[type_hue]} - {max_hue}{POSTFIX[type_hue]})"
645+
max_angle = target.channels[target.hue_index()].angle
646+
if max_angle == 360:
647+
xaxis = f"{names[axm[0]]} (0˚ - 360˚)"
648+
else:
649+
min_angle = target.channels[target.hue_index()].low
650+
type_angle = target.channels[target.hue_index()].angle
651+
xaxis = f"{names[axm[0]]} ({min_angle}{POSTFIX[type_angle]} - {max_angle}{POSTFIX[type_angle]})"
652+
651653
yaxis = str(names[axm[1]])
652654
zaxis = str(names[axm[2]])
653655

tools/gamut_3d_plotly.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from coloraide.channels import ANGLE_DEG
1818
from coloraide.spaces import HSLish, HSVish, HWBish, Labish, LChish, RGBish # noqa: E402
1919
from coloraide import algebra as alg # noqa: E402
20-
from coloraide.css.serialize import POSTFIX # noqa: E402
20+
from coloraide.color import POSTFIX # noqa: E402
2121

2222
FORCE_OWN_GAMUT = {'ryb', 'ryb-biased'}
2323

@@ -429,16 +429,18 @@ def plot_gamut_in_space(
429429
"gridcolor": gridcolor,
430430
"zerolinecolor": zerolinecolor,
431431
}
432-
min_hue = target.channels[target.hue_index()].low
433-
max_hue = target.channels[target.hue_index()].high
434-
type_hue = target.channels[target.hue_index()].hue
435432

436433
if not is_cyl:
437434
xaxis = str(names[axm[0]])
438-
elif max_hue == 360:
439-
xaxis = f"{names[axm[0]]} (0˚ - 360˚)"
440435
else:
441-
xaxis = f"{names[axm[0]]} ({min_hue}{POSTFIX[type_hue]} - {max_hue}{POSTFIX[type_hue]})"
436+
max_angle = target.channels[target.hue_index()].angle
437+
if max_angle == 360:
438+
xaxis = f"{names[axm[0]]} (0˚ - 360˚)"
439+
else:
440+
min_angle = target.channels[target.hue_index()].low
441+
type_angle = target.channels[target.hue_index()].angle
442+
xaxis = f"{names[axm[0]]} ({min_angle}{POSTFIX[type_angle]} - {max_angle}{POSTFIX[type_angle]})"
443+
442444
yaxis = str(names[axm[1]])
443445
zaxis = str(names[axm[2]])
444446

0 commit comments

Comments
 (0)