Skip to content

Commit

Permalink
4
Browse files Browse the repository at this point in the history
  • Loading branch information
villares committed Jan 5, 2025
1 parent 24f3f9b commit ab9bf15
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Binary file added 2025/sketch_2025_01_04/sketch_2025_01_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions 2025/sketch_2025_01_04/sketch_2025_01_04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import py5
from py5 import sin, cos, PI

def setup():
py5.size(800, 800)
py5.translate(400, 400)
py5.background(24)
py5.stroke(0)
py5.fill(0)
wave(390)
py5.save('out.png')

def wave(r):
vs = circle_arc_pts(0, 0, r, 0, py5.PI)
vs += reversed(circle_arc_pts(-r/2, 0, r/2, 0, py5.PI))
vs += reversed(circle_arc_pts(r/2, 0, r/2, 0, py5.PI))
with py5.begin_shape():
py5.vertices(vs)
if r > 20:
with py5.push_matrix():
py5.translate(-r/2, 0)
py5.rotate(py5.PI/3)
wave(r/2)
py5.rotate(-py5.PI/3)
py5.translate(r, 0)
py5.rotate(py5.PI/2)
wave(r/2)

def circle_arc_pts(x, y, radius, start, sweep):
return arc_pts(x, y, radius * 2, radius * 2, start, start + sweep)

def arc_pts(cx, cy, w, h, start_angle, end_angle, num_points=24):
sweep_angle = end_angle - start_angle
pts_list = []
step_angle = float(sweep_angle) / num_points
va = start_angle
side = 1 if sweep_angle > 0 else -1
while va * side < end_angle * side or abs(va - end_angle) < 0.0001:
pts_list.append((cx + cos(va) * w / 2.0,
cy + sin(va) * h / 2.0))
va += step_angle
return pts_list

py5.run_sketch()
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_04

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

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



---

### sketch_2025_01_03
Expand Down

0 comments on commit ab9bf15

Please sign in to comment.