@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
25 lines (24 loc) • 502 B
JavaScript
import { __copyShape } from "../internal/copy.js";
import { APC } from "./apc.js";
class Polygon extends APC {
type = "poly";
dim = 2;
add(...points) {
this.points.push(...points);
}
copy() {
return __copyShape(Polygon, this);
}
copyTransformed(fn) {
return __copyShape(Polygon, this, fn(this.points));
}
withAttribs(attribs) {
return new Polygon(this.points, attribs);
}
toHiccup() {
return ["polygon", this.attribs, this.points];
}
}
export {
Polygon
};