In [2]:
using PolygonClipping
using PyPlot

circle = Polygon()

x_max = 10
y_max = 10.2
circle_seg = 2*pi/100

r = min(x_max, y_max)/2

for i = 0:circle_seg:2*pi-circle_seg
    push!(circle, Vertex([r*cos(i)+x_max/2, r*sin(i)+y_max/2]))
end

for vert in circle
    x1, y1 = vert.location
    x2, y2 = vert.next.location
    plot([x1,x2], [y1,y2], color="red", linewidth=1.0, linestyle="-")
end

fill = Polygon()
push!(fill, Vertex([0.5,-1.5]))
scan = [-1.0,11.0]
for i = 0.5:9.5
    for j in scan
        push!(fill, Vertex([i,j]))
    end
    reverse!(scan)
end
push!(fill, Vertex([9.5,-1.5]))

for vert in fill
    x1, y1 = vert.location
    x2, y2 = vert.next.location
    plot([x1,x2], [y1,y2], color="blue", linewidth=1.0, linestyle="-")
end

clip = intersection(circle, fill)
for poly in clip
    for vert in poly
        x1, y1 = vert.location
        x2, y2 = vert.next.location
        plot([x1,x2], [y1,y2], color="green", linewidth=2.0, linestyle="-")
    end
end



In [ ]: