@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
53 lines • 1.69 kB
TypeScript
import type { Attribs } from "./api.js";
import type { Vec } from "@thi.ng/vectors";
import { Polygon } from "./api/polygon.js";
export declare const polygon: (pts?: Iterable<Vec>, attribs?: Attribs) => Polygon;
/**
* Syntax sugar for {@link starWithCentroid}, using `[0,0]` as center.
*
* @param r
* @param n
* @param profile
* @param attribs
*/
export declare const star: (r: number, n: number, profile: number[], attribs?: Attribs) => Polygon;
/**
* Creates a new "star"-shaped polygon around `pos` with radius `r` and `n`
* repetitions of `profile`. The latter is an array of radius scale values to
* define the overall shape. The resulting polygon will have `n *
* profile.length` vertices. To create an actual star-like shape, the profile
* needs to contain at least 2 values, e.g. `[1, 0.5]`, meaning every other
* vertex will be inset to 50% of the base radius.
*
* @example
* ```ts tangle:../export/star-with-centroid.ts
* import { starWithCentroid } from "@thi.ng/geom";
*
* console.log(
* starWithCentroid([100,200], 50, 5, [1, 0.5])
* );
* // Polygon {
* // points: [
* // [150.000, 200.000],
* // [120.225, 214.695],
* // [115.451, 247.553],
* // [92.275, 223.776],
* // [59.549, 229.389],
* // [75.000, 200.000],
* // [59.549, 170.611],
* // [92.275, 176.224],
* // [115.451, 152.447],
* // [120.225, 185.305]
* // ],
* // attribs: undefined
* // }
* ```
*
* @param pos
* @param r
* @param n
* @param profile
* @param attribs
*/
export declare const starWithCentroid: (pos: Vec, r: number, n: number, profile: number[], attribs?: Attribs) => Polygon;
//# sourceMappingURL=polygon.d.ts.map