Skip to content

Commit

Permalink
26
Browse files Browse the repository at this point in the history
  • Loading branch information
villares committed Jan 27, 2025
1 parent 975065e commit 5647aa3
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
Binary file added 2025/sketch_2025_01_26/sketch_2025_01_26.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions 2025/sketch_2025_01_26/sketch_2025_01_26.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from shapely import Polygon
import py5

def setup():
py5.size(600, 600)
start()

def start():
global ps
crossing = True
while crossing:
pts_a = [(py5.random_int(1, 20) * 10,
py5.random_int(1, 20) * 10)
for _ in range(5)]
pts_b = [(y, -x) for x, y in pts_a]
pts = pts_a + pts_b
p = Polygon(pts)
p_mirror = Polygon([(-x, y) for x, y in pts])
p_mirror = p_mirror.union(p)
crossing = not p_mirror.is_simple
ps = [p_mirror]

def draw():
py5.background(230, 240, 240)
py5.translate(py5.width / 2, py5.height / 2)
py5.no_fill()
for p in ps:
py5.shape(py5.convert_cached_shape(p))

def shrink():
p = ps[-1]
new_p = p.buffer(-10, cap_style='round')
print(new_p.area)
while new_p.area > 0:
ps.append(new_p)
new_p = ps[-1].buffer(-10, cap_style='round')

def grow():
p = ps[-1]
new_p = p.buffer(10, cap_style='round')
print(new_p.area)
while new_p.area < 1000000:
ps.append(new_p)
new_p = ps[-1].buffer(10, cap_style='round')


def key_pressed():
if py5.key == 's':
py5.save_frame('out###.png')
elif py5.key == ' ':
start()
elif py5.key == 'a':
shrink()
elif py5.key == 'z':
grow()

py5.run_sketch(block=False)
10 changes: 10 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_01_26

![sketch_2025_01_26](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_01_26/sketch_2025_01_26.gif)

[sketch_2025_01_26](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_01_26) [[py5](https://py5coding.org/)]



---

### sketch_2025_01_25
Expand Down

0 comments on commit 5647aa3

Please sign in to comment.