Skip to content

Instantly share code, notes, and snippets.

@baku89
Created March 19, 2024 14:40
Show Gist options
  • Save baku89/06d77bec1a8eb3aaf1f887a2fb8c83d8 to your computer and use it in GitHub Desktop.
Save baku89/06d77bec1a8eb3aaf1f887a2fb8c83d8 to your computer and use it in GitHub Desktop.
c = transform(
subdiv(arc([50, 50], 20, 0, 720), 6),
mat2d.rotation(time * 120, [50, 50])
)
w = spawn(c, (s, i) => {
t = sinwave(i / segmentCount(c) * 3 - time)
dir = i % 2 === 0 ? 1 : -1
p0 = Segment.point(s, 0)
p1 = Segment.point(s, 1)
n0 = Segment.normal(s, 0)
n1 = Segment.normal(s, 1)
angle = vec2.angle(
vec2.rotate90(n0),
vec2.rotate90(n1, false)
) + (dir > 0 ? 360 : 0)
amp = (dir > 0 ? -10 : 10) * t
q0 = vec2.scaleAndAdd(p0, n0, amp)
q1 = vec2.scaleAndAdd(p1, n1, amp)
return join([
line(p0, q0),
arcByPointsAngle(q0, q1, angle),
line(q1, p1),
])
})
stroke(w, '', 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment