Skip to content

Commit 02a1869

Browse files
committed
harder lines readability
1 parent 23f2ed9 commit 02a1869

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

justpyplot/justpyplot.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,13 +1752,20 @@ def plot(values: np.array,
17521752
xx, yy = np.meshgrid(x_offset, y_offset)
17531753
mask = xx**2 + yy**2 <= r**2
17541754

1755+
#mask to separate shape out of bounded rectangle
17551756
xx = xx[mask]
17561757
yy = yy[mask]
17571758

1759+
# 1st - despise the term 'ravel', its more 'unravel' and even more 'straighten'
1760+
# 2nd - this hack allows stamped form vectorized rendering
1761+
# by using the fact that reshaped indexing on both pairs keeps matching exactly
17581762
xx = xx.reshape(1, -1) + valsx.reshape(-1, 1)
17591763
yy = yy.reshape(1, -1) + valsy.reshape(-1, 1)
1760-
1764+
# now all point pixels are there in straightened form
1765+
1766+
#cut out pixels that are out of bounds
17611767
valid_points = (0 <= xx) & (xx < figure_img.shape[1]) & (0 <= yy) & (yy < figure_img.shape[0])
1768+
#fold points back into plot tensor asigning their places color
17621769
figure_img[yy[valid_points], xx[valid_points]] = point_color
17631770

17641771

0 commit comments

Comments
 (0)