Simpler Yin-Yang?

I wanted to draw the Yin-Yang symbol in Luxor.jl.
Here’s what I came up with. Can this be done more idiomatic?
I would have preferred the white “eye” of the black “fish” to be just a cut-out rather than over-plotting with white. However, I was not able to figure out how.

using Luxor
R = 128
@png begin
    move(Point(0,-R))                            # start at top
    arc(Point(0,0), R, -pi/2, pi/2, :path)       # right side arc to bottom
    arc(Point(0,R/2), R/2, pi/2, -pi/2, :path)   # small arc up
    carc(Point(0,-R/2), R/2,  pi/2, -pi/2,:path) # small arc counter-clockwise
    fillpath()
    circle(Point(0,0), R, action=:stroke)        # large circle
    circle(Point(0,-R/2), R/8, action=:fill)     # white fish eye
    sethue("white")
    circle(Point(0,R/2), R/8, action=:fill)      # black fish eye
end 

My eye doesn’t like the discontinuity in the second derivative that arises when you glue two arcs together. Maybe a spline would be better?

2 Likes

Your version is fine. You could add a circular hole as a subpath of the shape:

R = 220
function y()
    arc(O, R, 0, π)
    arc(O - (R/2, 0), R/2, π, 0)
    carc(O + (R/2, 0), R/2, π, 0)
    newsubpath()
    circlepath(O - (R/2, 0), R/5, reversepath=false)
end

@draw begin
    background("maroon")
    for i in 1:2
        sethue(["black", "white"][i])
        y()
        fillpath()
        rotate(π)
    end
end

But I can’t think of a way to smooth out that jump from one semicircle to the next…