UNPKG

@thi.ng/geom

Version:

Functional, polymorphic API for 2D geometry types & SVG generation

30 lines (29 loc) 633 B
import { set2 } from "@thi.ng/vectors/set"; import { __asVec } from "../internal/args.js"; import { __copyAttribs } from "../internal/copy.js"; class Ellipse { constructor(pos = [0, 0], r = [1, 1], attribs) { this.pos = pos; this.attribs = attribs; this.r = __asVec(r); } type = "ellipse"; dim = 2; r; copy() { return new Ellipse( set2([], this.pos), set2([], this.r), __copyAttribs(this.attribs) ); } withAttribs(attribs) { return new Ellipse(this.pos, this.r, attribs); } toHiccup() { return [this.type, this.attribs, this.pos, this.r]; } } export { Ellipse };