diff --git a/2024/sketch_2024_12_06/sketch_2024_12_06.gif b/2024/sketch_2024_12_06/sketch_2024_12_06.gif new file mode 100644 index 00000000..9e1f20f6 Binary files /dev/null and b/2024/sketch_2024_12_06/sketch_2024_12_06.gif differ diff --git a/2024/sketch_2024_12_06/sketch_2024_12_06.py b/2024/sketch_2024_12_06/sketch_2024_12_06.py new file mode 100644 index 00000000..3f5a946d --- /dev/null +++ b/2024/sketch_2024_12_06/sketch_2024_12_06.py @@ -0,0 +1,27 @@ +import numpy as np +import py5 +from skimage import measure + +# from https://scikit-image.org/docs/stable/auto_examples/edges/plot_contours.html +x, y = np.ogrid[-np.pi : np.pi : 400j, -np.pi : np.pi : 400j] +r = np.sin(np.exp(np.sin(x) ** 3 + np.cos(y) ** 2)) +r = r.T +r *= 255 + +def setup(): + global img + py5.size(400, 400) + py5.color_mode(py5.HSB) + img = py5.create_image_from_numpy(r.T, 'L') + +def draw(): + py5.image(img, 0, 0) + t = py5.mouse_x / py5.width * 255 + contours = measure.find_contours(r, t) + + for i, contour in enumerate(contours): + py5.fill(i * 32, 255, 255, 150) + with py5.begin_closed_shape(): + py5.vertices(contour) + +py5.run_sketch(block=False) \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 83c31906..1552967e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,6 +30,16 @@ Here are listed some of the tools I have been using more recently: 2024 \| [2023](2023.md) \| [2022](2022.md) \| [2021](2021.md) \| [2020](2020.md) \| [2019](2019.md) \| [2018](2018.md) +--- + +### sketch_2024_12_06 + +![sketch_2024_12_06](https://raw.githubusercontent.com/villares/sketch-a-day/main/2024/sketch_2024_12_06/sketch_2024_12_06.gif) + +[sketch_2024_12_06](https://github.com/villares/sketch-a-day/tree/main/2024/sketch_2024_12_06) [[py5](https://py5coding.org/)] + + + --- ### sketch_2024_12_05