From 042b1a220a9058f254016c247294f31a4e181b9b Mon Sep 17 00:00:00 2001 From: jay817 Date: Sun, 13 Oct 2024 12:48:53 -0400 Subject: [PATCH] Add color-palette/README.md --- color-palette/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 color-palette/README.md diff --git a/color-palette/README.md b/color-palette/README.md new file mode 100644 index 0000000..e91df21 --- /dev/null +++ b/color-palette/README.md @@ -0,0 +1,18 @@ +```python +# https://iquilezles.org/articles/palettes/ +import numpy as np + +W, H = 800, 20 +imgs = [] +for _ in range(50): + a, b, c, d = np.random.rand(4, 3) + # b = a * b + # c = np.ones(3) + palette = lambda t: np.clip(a + b * np.cos(np.pi * (c * t + d)), 0, 1) + line = [palette(t) for t in np.linspace(0, 1, W)] + img = np.stack([line] * H) + img = (img * 255).astype(np.uint8) + imgs.append(img) +img = np.vstack(imgs) +__import__('PIL.Image').Image.fromarray(img) +``` \ No newline at end of file