Skip to content

Commit

Permalink
feat(Polygon): add scale method
Browse files Browse the repository at this point in the history
  • Loading branch information
meszaros-lajos-gyorgy committed Sep 13, 2023
1 parent 8a6e748 commit b3147b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ export class Polygon {
})
}

scale(scale: number) {
this.vertices.forEach((vertex) => {
vertex.multiplyScalar(scale)
})
}

equals(polygon: Polygon, epsilon: number = 0) {
if (this.isQuad() !== polygon.isQuad()) {
return false
Expand Down
6 changes: 6 additions & 0 deletions src/Polygons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ export class Polygons extends Array<Polygon> {
})
}

scale(scale: number) {
this.forEach((polygon) => {
polygon.scale(scale)
})
}

empty() {
this.length = 0
}
Expand Down

0 comments on commit b3147b2

Please sign in to comment.