(closeMode = constants.OPEN, _index = this.contours.length - 1)
| 1033 | } |
| 1034 | |
| 1035 | endContour(closeMode = constants.OPEN, _index = this.contours.length - 1) { |
| 1036 | const contour = this.at(_index); |
| 1037 | if (closeMode === constants.CLOSE) { |
| 1038 | // shape characteristics |
| 1039 | const isPath = contour.kind === constants.PATH; |
| 1040 | |
| 1041 | // anchor characteristics |
| 1042 | const anchorVertex = this.at(_index, 0, 0); |
| 1043 | const anchorHasPosition = Object.hasOwn(anchorVertex, 'position'); |
| 1044 | const lastSegment = this.at(_index, -1); |
| 1045 | |
| 1046 | // close path |
| 1047 | if (isPath && anchorHasPosition) { |
| 1048 | if (lastSegment.handlesClose()) { |
| 1049 | lastSegment.close(anchorVertex); |
| 1050 | } else { |
| 1051 | // Temporarily remove contours after the current one so that we add to the original |
| 1052 | // contour again |
| 1053 | const rest = this.contours.splice( |
| 1054 | _index + 1, |
| 1055 | this.contours.length - _index - 1 |
| 1056 | ); |
| 1057 | const prevVertexProperties = this.#vertexProperties; |
| 1058 | this.#vertexProperties = { ...prevVertexProperties }; |
| 1059 | for (const key in anchorVertex) { |
| 1060 | if (['position', 'textureCoordinates'].includes(key)) continue; |
| 1061 | this.#vertexProperties[key] = anchorVertex[key]; |
| 1062 | } |
| 1063 | this.vertex( |
| 1064 | anchorVertex.position, |
| 1065 | anchorVertex.textureCoordinates, |
| 1066 | { isClosing: true } |
| 1067 | ); |
| 1068 | this.#vertexProperties = prevVertexProperties; |
| 1069 | this.contours.push(...rest); |
| 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | beginShape(shapeKind = constants.PATH) { |
| 1076 | this.kind = shapeKind; |
no test coverage detected