Skip to content

Commit 87b6fd8

Browse files
committed
Tool updates
- Clean out dead code - Update some stylistic things
1 parent 62f5a90 commit 87b6fd8

File tree

5 files changed

+19
-93
lines changed

5 files changed

+19
-93
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,8 @@ <h1>ColorAide Color Space Models</h1>
875875
gmap,
876876
simulate_alpha,
877877
interp_gmap,
878-
filters=()
878+
filters=(),
879+
opacity=1
879880
):
880881
"""Plot interpolations."""
881882

@@ -891,10 +892,7 @@ <h1>ColorAide Color Space Models</h1>
891892
options = interp_method.copy()
892893
options['steps'] = len(inputs)
893894

894-
markers = Color.steps(
895-
interp_colors.split(';'),
896-
**options
897-
)
895+
markers = [Color(i) for i in interp_colors.split(';')]
898896

899897
target = Color.CS_MAP[space]
900898
flags = {
@@ -936,10 +934,12 @@ <h1>ColorAide Color Space Models</h1>
936934
trace = go.Scatter3d(
937935
x=x, y=y, z=z,
938936
mode = 'lines',
939-
line={'color': cmap, 'width': 8},
937+
line={'color': cmap, 'width': 16},
940938
showlegend=False
941939
)
942940

941+
if opacity < 1:
942+
trace.update(opacity=opacity)
943943
fig.add_trace(trace)
944944

945945

41 KB
Loading
20.3 KB
Loading

tools/gamut_3d_plotly.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ def plot_interpolation(
664664
gmap,
665665
simulate_alpha,
666666
interp_gmap,
667-
filters=()
667+
filters=(),
668+
opacity=1
668669
):
669670
"""Plot interpolations."""
670671

@@ -680,10 +681,7 @@ def plot_interpolation(
680681
options = interp_method.copy()
681682
options['steps'] = len(inputs)
682683

683-
markers = Color.steps(
684-
interp_colors.split(';'),
685-
**options
686-
)
684+
markers = [Color(i) for i in interp_colors.split(';')]
687685

688686
target = Color.CS_MAP[space]
689687
flags = {
@@ -725,10 +723,12 @@ def plot_interpolation(
725723
trace = go.Scatter3d(
726724
x=x, y=y, z=z,
727725
mode = 'lines',
728-
line={'color': cmap, 'width': 8},
726+
line={'color': cmap, 'width': 16},
729727
showlegend=False
730728
)
731729

730+
if opacity < 1:
731+
trace.update(opacity=opacity)
732732
fig.add_trace(trace)
733733

734734

tools/plot_raytrace.py

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -15,78 +15,6 @@
1515
from coloraide.channels import ANGLE_DEG # noqa: E402
1616

1717

18-
def plot_interpolation(
19-
fig,
20-
space,
21-
interp_colors,
22-
interp_space,
23-
interp_method,
24-
hue,
25-
carryfoward,
26-
powerless,
27-
extrapolate,
28-
steps,
29-
gmap
30-
):
31-
"""Plot interpolations, but force Lab to operate like LCh."""
32-
33-
if not interp_colors:
34-
return
35-
36-
colors = Color.steps(
37-
interp_colors.split(';'),
38-
space=interp_space,
39-
steps=steps,
40-
hue=hue,
41-
carryfoward=carryfoward,
42-
powerless=powerless,
43-
extrapolate=extrapolate,
44-
method=interp_method
45-
)
46-
47-
target = Color.CS_MAP[space]
48-
flags = {
49-
'is_cyl': target.is_polar(),
50-
'is_labish': isinstance(target, plt3d.Labish),
51-
'is_lchish': isinstance(target, plt3d.LChish),
52-
'is_hslish': isinstance(target, plt3d.HSLish),
53-
'is_hwbish': isinstance(target, plt3d.HWBish),
54-
'is_hsvish': isinstance(target, plt3d.HSVish)
55-
}
56-
57-
x = []
58-
y = []
59-
z = []
60-
cmap = []
61-
for c in colors:
62-
c.convert(space, in_place=True)
63-
plt3d.store_coords(c, x, y, z, flags)
64-
65-
c.convert('srgb', in_place=True)
66-
c.fit(**gmap)
67-
cmap.append(c.to_string(hex=True))
68-
69-
trace = go.Scatter3d(
70-
x=x, y=y, z=z,
71-
mode='lines',
72-
line={'color': cmap, 'width': 16},
73-
showlegend=False
74-
)
75-
76-
trace.update(opacity=0.5)
77-
fig.add_trace(trace)
78-
79-
trace = go.Scatter3d(
80-
x=[x[0], x[-1]], y=[y[0], y[-1]], z=[z[0], z[-1]],
81-
mode='markers',
82-
marker={'color': [cmap[0], cmap[-1]]},
83-
showlegend=False
84-
)
85-
86-
trace.update(opacity=1)
87-
fig.add_trace(trace)
88-
89-
9018
def raytrace(args):
9119
"""Test ray tracing directly."""
9220

@@ -300,7 +228,7 @@ def simulate_raytrace_gamut_mapping(args):
300228
indexes[:] = indexes[1], indexes[2], indexes[0]
301229
points[e] = [temp[i] for i in indexes]
302230

303-
x, y, z = zip(*points)
231+
x, y, z = zip(*points) if points else ([], [], [])
304232
data = []
305233
i = 0
306234
while i < len(x):
@@ -318,7 +246,7 @@ def simulate_raytrace_gamut_mapping(args):
318246
# Plot the color space
319247
fig = plt3d.plot_gamut_in_space(
320248
space if mode == 'rgb' else pspace,
321-
{args.gamut_rgb: {'opacity': 0.2, 'resolution': 100}},
249+
{args.gamut_rgb: {'opacity': 0.2, 'resolution': 10 if mode == 'rgb' else 100}},
322250
title=args.title,
323251
gmap=gmap,
324252
size=(args.width, args.height)
@@ -327,18 +255,16 @@ def simulate_raytrace_gamut_mapping(args):
327255
fig.add_traces(data)
328256

329257
if args.gamut_interp:
330-
plot_interpolation(
258+
plt3d.plot_interpolation(
331259
fig,
332260
space if mode == 'rgb' else pspace,
333261
first.to_string(fit=False) + ';' + achroma.to_string(fit=False),
334-
pspace,
335-
'linear',
336-
'shorter',
337-
False,
262+
{"method": "linear", "hue": "shorter", "steps": 100},
263+
gmap,
338264
False,
339265
False,
340-
100,
341-
gmap
266+
(),
267+
opacity=0.5
342268
)
343269

344270
return fig

0 commit comments

Comments
 (0)