Skip to content

Commit

Permalink
3b
Browse files Browse the repository at this point in the history
  • Loading branch information
villares committed Jan 4, 2025
1 parent 917242c commit 24f3f9b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
Binary file added 2025/sketch_2025_01_03/sketch_2025_01_03b.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_03b.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, 255 - r / 2, 255)
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 > 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, 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()
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ If you appreciate what I have been doing, you may also support my artistic work,

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

The next day I think I improved it:

![sketch_2025_01_03b](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_01_03/sketch_2025_01_03b.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"
Expand Down

0 comments on commit 24f3f9b

Please sign in to comment.