Update color-palette/README.md

This commit is contained in:
2024-10-13 12:52:37 -04:00
parent afab1f0254
commit 09d445c889

View File

@@ -2,6 +2,7 @@
''
# https://iquilezles.org/articles/palettes/
import numpy as np
show = lambda img: __import__('PIL.Image').Image.fromarray(img)
W, H = 800, 40
imgs = []
@@ -14,9 +15,8 @@ for _ in range(20):
img = (img * 255).astype(np.uint8)
imgs.append(img)
img = np.vstack(imgs)
__import__('PIL.Image').Image.fromarray(img)
show(img)
''
import numpy as np
a, b, c, d = np.array([
[.5, .5, .5],
[.5, .5, .5],
@@ -27,7 +27,6 @@ W, H = 800, 20
palette = lambda t: np.clip(a + b * np.cos(2 * np.pi * (c * t + d)), 0, 1)
line = [palette(t) for t in np.linspace(0, 1, W)]
img = (np.stack([line] * H) * 255).astype(np.uint8)
__import__('PIL.Image').Image.fromarray(img)
show(img)
''
```