Skip to content

Commit

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

def setup():
py5.size(800, 800)
py5.translate(400, 400)
py5.background(0)
py5.no_stroke()
wave(390)

def wave(r):
py5.fill(255 - r / 2)
with py5.begin_closed_shape():
py5.vertices(circle_arc_pts(0, 0, r, 0, py5.PI))
if r > 4:
with py5.push_matrix():
py5.translate(-r/2, 0)
py5.rotate(PI / 3)
wave(r/2)
py5.rotate(-PI / 3)
py5.translate(r, 0)
wave(r/2)

def circle_arc_pts(x, y, radius, start_ang, sweep_ang, **kwargs):
return arc_pts(x, y, radius * 2, radius * 2, start_ang, start_ang + sweep_ang, **kwargs)

def arc_pts(cx, cy, w, h, start_angle, end_angle, num_points=24, seg_len=None):
sweep_angle = end_angle - start_angle
if abs(sweep_angle) < 0.0001:
return [(cx + cos(start_angle) * w / 2.0, cy + sin(start_angle) * h / 2.0)]
if seg_len:
num_points = abs(sweep_angle * (w + h) / 4) / seg_len
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_03

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

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

#genuary3 #genuary2025 "42 lines of code"

---

### sketch_2025_01_02
Expand Down

0 comments on commit 917242c

Please sign in to comment.