(polygon, offset, arcSegments)
| 128 | return marginPolygon; |
| 129 | } |
| 130 | function createPaddingPolygon(polygon, offset, arcSegments) { |
| 131 | const offsetEdges = []; |
| 132 | for (let i = 0; i < polygon.edges.length; i++) { |
| 133 | const edge = polygon.edges[i]; |
| 134 | const dx = edge.inwardNormal.x * offset; |
| 135 | const dy = edge.inwardNormal.y * offset; |
| 136 | offsetEdges.push(createOffsetEdge(edge, dx, dy)); |
| 137 | } |
| 138 | const vertices = []; |
| 139 | for (let i = 0; i < offsetEdges.length; i++) { |
| 140 | const thisEdge = offsetEdges[i]; |
| 141 | const prevEdge = offsetEdges[(i + offsetEdges.length - 1) % offsetEdges.length]; |
| 142 | const vertex = edgesIntersection(prevEdge, thisEdge); |
| 143 | if (vertex && (!vertex.isIntersectionOutside || arcSegments < 1)) { |
| 144 | vertices.push({ |
| 145 | x: vertex.x, |
| 146 | y: vertex.y |
| 147 | }); |
| 148 | } else { |
| 149 | const arcCenter = polygon.edges[i].vertex1; |
| 150 | appendArc(arcSegments, vertices, arcCenter, offset, prevEdge.vertex2, thisEdge.vertex1, true); |
| 151 | } |
| 152 | } |
| 153 | const paddingPolygon = createPolygon(vertices); |
| 154 | paddingPolygon.offsetEdges = offsetEdges; |
| 155 | return paddingPolygon; |
| 156 | } |
| 157 | function offsetPolygon(vertices, offset, arcSegments = 0) { |
| 158 | const polygon = createPolygon(vertices); |
| 159 | if (offset > 0) { |
no test coverage detected