Skip to content

Commit 98411f8

Browse files
committed
Harmony diagram tool updates
- Use the polar space when performing chroma reduction - Protect against zero divide - Ensure scatter plot size is actually respected - Use a larger default resolution for plot depth
1 parent a745139 commit 98411f8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/harmony_diagram.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def plot_slice(
120120
hue, chroma, lightness = cs.names()
121121
else:
122122
lightness, chroma, hue = cs.names()
123+
pspace = cs.NAME
123124

124125
# Interpolate between each x axis color along the y axis
125126
cmap = []
@@ -130,23 +131,23 @@ def plot_slice(
130131
custom[hue] = h
131132
custom[lightness] = constant
132133
custom[chroma] = max_chroma
133-
custom.fit(gamut, method=gmap)
134+
custom.fit(gamut, method=gmap, pspace=pspace)
134135
mx = custom[chroma]
135136
chromas = []
136137
for c in alg.linspace(0, mx, res):
137138
custom[lightness] = constant
138139
custom[chroma] = c
139140
theta.append(h)
140141
chromas.append(c)
141-
cmap.append(custom.convert('srgb').to_string(hex=True, fit=gmap))
142+
cmap.append(custom.convert('srgb').to_string(hex=True, fit=gmap, pspace=pspace))
142143
maximums.append((h, mx))
143-
r.extend(alg.divide(chromas, mx))
144+
r.extend([alg.zdiv(ci, mx) for ci in chromas])
144145

145146
fig.add_traces(data=go.Scatterpolar(
146147
r=r,
147148
theta=theta,
148149
mode='markers',
149-
marker={'color': cmap, 'size': 16},
150+
marker={'color': cmap, 'size': scatter_size},
150151
showlegend=False
151152
))
152153

@@ -165,7 +166,7 @@ def main():
165166
parser.add_argument('--map-colors', '-m', action='store_true', help="Gamut map colors to be within the gamut.")
166167
parser.add_argument('--gamut-map-method', '-f', default="raytrace", help="Gamut mapping space.")
167168
parser.add_argument('--title', '-t', default='', help="Provide a title for the diagram.")
168-
parser.add_argument('--resolution', '-r', type=int, default=400, help="How densely to render the figure.")
169+
parser.add_argument('--resolution', '-r', type=int, default=500, help="How densely to render the figure.")
169170
parser.add_argument('--scatter-size', '-S', type=int, default=4, help="Define scatter plot size.")
170171
parser.add_argument('--output', '-o', default='', help='Output file.')
171172
parser.add_argument('--height', '-H', type=int, default=800, help="Height")

0 commit comments

Comments
 (0)