first sketch union

This commit is contained in:
Stewart Allen 2024-07-25 15:52:17 -04:00
commit 54ffc506bd
4 changed files with 172 additions and 28 deletions

View file

@ -110,6 +110,19 @@ class Polygon {
return this;
}
toObject() {
return {
points: this.toArray(),
inner: this.inner?.map(i => i.toArray())
};
}
fromObject(obj) {
this.fromArray(obj.points);
this.inner = obj.inner?.map(a => newPolygon().fromArray(a))
return this;
}
matches(poly) {
let tarr = Array.isArray(poly) ? poly : poly.toArray();
let parr = this.toArray();