Alexandre B A Villares 2025-04-11 12:47:36 -03:00
rodzic e4d4fca3ce
commit 98c606f2d9
4 zmienionych plików z 49 dodań i 24 usunięć

Wyświetl plik

@ -1,24 +0,0 @@
import py5
import shapely
def setup():
py5.size(200, 200)
py5.shape_mode(py5.CENTER)
shp = py5.create_shape(py5.GROUP)
square = py5.create_shape(py5.RECT, 0, 0, 80, 80)
shp.add_child(square)
py5.shape(shp, 100, 100) # seemengly drawn from corner
other = py5.create_shape()
other.begin_shape()
other.no_fill()
other.vertex(0, 0)
other.vertex(80, 0)
other.vertex(80, 80)
other.vertex(0, 80)
other.end_shape(py5.CLOSE)
py5.shape(other, 100, 100) # drawn as espected
py5.run_sketch(block=False)

Plik binarny nie jest wyświetlany.

Po

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

Wyświetl plik

@ -0,0 +1,39 @@
import py5
import shapely
def setup():
py5.size(400, 400)
py5.color_mode(py5.HSB)
s = 10
lines = []
for i in range(30):
x = i * s
y = 100 - i * s
ls = shapely.LineString(((x * 0.8, y * 1.3),
(x * 1.4 + 100, y * 0.5 + 100)))
lines.append(ls)
collection = shapely.GeometryCollection(lines).buffer(5)
clipped = clip_rect(collection, 50, 50, 80, 80)
py5.no_stroke()
shp = py5.convert_shape(clipped)
shp.disable_style()
for x in range(40, py5.width, 80):
for y in range(40, py5.height, 80):
with py5.push_matrix():
py5.translate(x, y)
py5.rotate(py5.radians(py5.random_choice((
0, 90, 180, 270
))))
for i, sub in enumerate(shp.get_children()):
py5.fill(i * 25, 200, 200)
py5.shape(sub, 0, 0)
py5.save_frame('out.png')
def clip_rect(shp, x, y, w, h):
global rect
rect = shapely.Polygon(((x, y), (x + w, y), (x + w, y + h), (x, y + h)))
intersection = rect.intersection(shp)
return shapely.affinity.translate(intersection,
-x - w / 2, -y - h / 2)
py5.run_sketch(block=False)

Wyświetl plik

@ -21,6 +21,16 @@ If you appreciate what I have been doing, you may also support my artistic work,
2025 \| [<b>2024</b>](2024.md) \| [<b>2023</b>](2023.md) \| [<b>2022</b>](2022.md) \| [<b>2021</b>](2021.md) \| [<b>2020</b>](2020.md) \| [<b>2019</b>](2019.md) \| [<b>2018</b>](2018.md)
---
### sketch_2025_04_10
![sketch_2025_04_10](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_04_10/sketch_2025_04_10.png)
[sketch_2025_04_10](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_04_10) [[py5](https://py5coding.org/)]
---
### sketch_2025_04_09