Search code examples
javascriptcanvaspaperjs

Draw a circle with a circle void inside with paperjs


Draw a steel pipe section in paperjs. It's only a circle with a void circle inside. Just like this:

Typical steel pipe section

So far I have tried joins, intersections, subtractions, adds, but I am not able to achieve that simple task.


Solution

  • .subtract() is the correct method. Found it in paperjs.org examples

    const outer = new paper.Path.Circle(position, diameter/2)
    const inner = new paper.Path.Circle(position, diameter/2-thickness)
    pipe_section = outer.subtract(inner)