How to achieve 'donut holes' with paths in Raphael

后端 未结 4 741
感动是毒
感动是毒 2020-12-05 11:41

I\'d like to draw a shape which has holes in it such that I can fill the shape it and not have the holes filled with that colour (leave them transparent).

4条回答
  •  执念已碎
    2020-12-05 12:41

    To make this work in Firefox 3.6, you need to close the hole; i.e. make the coordinates join back to themselves when defining the inner boundary. Curiously, this doesn't appear necessary for the outer boundary.

    paper.path("M 50 50 L 50 150 L 150 150 L 150 50 z" +
              " M 75 75 L 125 75 L 125 125 L 75 125 L 75 75 z")
    .attr("fill", "#f00");
    

    Just a quick note to follow up on the comment - the clockwise/counter-clockwise concept might seem strange at first, but it's pretty standard throughout GIS / CAD technologies.

提交回复
热议问题