diff --git a/2025/sketch_2025_01_03/sketch_2025_01_03b.png b/2025/sketch_2025_01_03/sketch_2025_01_03b.png new file mode 100644 index 00000000..e683306c Binary files /dev/null and b/2025/sketch_2025_01_03/sketch_2025_01_03b.png differ diff --git a/2025/sketch_2025_01_03/sketch_2025_01_03b.py b/2025/sketch_2025_01_03/sketch_2025_01_03b.py new file mode 100644 index 00000000..513745a1 --- /dev/null +++ b/2025/sketch_2025_01_03/sketch_2025_01_03b.py @@ -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() \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 56d33fb4..72d634ba 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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"