Alexandre B A Villares 2025-10-18 21:32:37 -03:00
rodzic 07f58ec85a
commit fe5fc3a22b
3 zmienionych plików z 46 dodań i 0 usunięć

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 366 KiB

Wyświetl plik

@ -0,0 +1,36 @@
# exploring some of Jim's ideas for the Python Brasil tutorial
import numpy as np
from shapely import unary_union, make_valid
from shapely.geometry import MultiPolygon, Polygon, Point
import py5
def setup():
global max_area
py5.size(500, 500)
py5.color_mode(py5.CMAP, 'viridis_r', 255)
py5.no_stroke()
generate()
def generate():
global result
shapes = Polygon([(py5.random_int(-5, 5) * 40, py5.random_int(-5, 5) * 40)
for _ in range(40)])
all_shapes = make_valid(shapes).buffer(-2)
result = all_shapes.buffer(2).difference(all_shapes.buffer(-4))
if isinstance(result, Polygon):
result = MultiPolygon([result])
def draw():
py5.background('black')
max_area = max(shp.area for shp in result.geoms)
py5.translate(250, 250)
for shp in result.geoms:
py5.fill(shp.area / max_area * 255)
py5.shape(shp)
def key_pressed():
py5.save_frame('####.png')
generate()
py5.run_sketch(block=False)

Wyświetl plik

@ -26,6 +26,16 @@ If you appreciate what I have been doing, you may also support my artistic work,
<!-- SKETCHES_START -->
---
### sketch_2025_10_18
![sketch_2025_10_18](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_10_18/sketch_2025_10_18.gif)
[sketch_2025_10_18](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_10_18) [[py5](https://py5coding.org/)]
---
### sketch_2025_10_17