Add color-palette/README.md
This commit is contained in:
18
color-palette/README.md
Normal file
18
color-palette/README.md
Normal file
@@ -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)
|
||||
```
|
||||
Reference in New Issue
Block a user