@thi.ng/hiccup-svg
Version:
SVG element functions for @thi.ng/hiccup & related tooling
71 lines • 2.78 kB
TypeScript
import type { Attribs, Vec2Like } from "./api.js";
import type { Maybe } from "@thi.ng/api";
export declare let PRECISION: number;
/**
* Sets the number of fractional digits used for formatting various floating
* point values in the serialized SVG. The current value can be read via
* {@link PRECISION}.
*
* @param n
*/
export declare const setPrecision: (n: number) => number;
/** @internal */
export declare const ff: (x: number) => string;
/** @internal */
export declare const fpoint: (p: Vec2Like) => string;
/** @internal */
export declare const fpoints: (pts: Vec2Like[], sep?: string) => string;
/**
* Takes an attributes object and converts any `fill`, `stroke` or
* transformation attributes, i.e. `transform`, `rotate`, `scale`, `translate`.
*
* @remarks
* If the element has a `transform` attrib, conversion of the other attribs will
* be skipped, else the values are assumed to be either strings or:
*
* - `transform`: 6-element numeric array (mat23)
* - `translate`: 2-element array
* - `rotate`: number (angle in radians)
* - `scale`: number (uniform scale) or 2-elem array
*
* If no `transform` is given, the resulting transformation order will always be
* TRS. Any string values given will be used as-is and therefore need to be
* complete, e.g. `{ rotate: "rotate(60)" }`
*
* For color related attribs (`fill`, `stroke`), if given value is array-like, a
* number or an
* [`IColor`](https://docs.thi.ng/umbrella/color/interfaces/IColor.html)
* instance, it will be converted into a CSS color string using
* [`css`](https://docs.thi.ng/umbrella/color/functions/css.html).
*
* String color attribs prefixed with `$` are replaced with `url(#...)` refs
* (used for referencing gradients).
*
* Additional attribute names given (via rest args) will be formatted as numeric
* values (using configured precision, see {@link setPrecision}). Formatting is
* done via {@link __numericAttribs}.
*
* Returns updated attribs or `undefined` if `attribs` itself is null-ish.
*
* @param attribs - attributes object
* @param numericIDs - numeric attribute names
*
* @internal
*/
export declare const fattribs: (attribs: Maybe<Attribs>, ...numericIDs: string[]) => Attribs;
/**
* Attempts to convert a single color attrib value. If `col` is prefixed with
* `$`, the value will be converted into a `url(#...)` reference. If not a
* string already, it will be converted into a CSS color string using
* [`css`](https://docs.thi.ng/umbrella/color/functions/css.html)
*
* {@link fattribs}
*
* @param col - color value
*
* @internal
*/
export declare const fcolor: (col: any) => string;
/** @internal */
export declare const withoutKeys: (src: Record<string, any>, keys: Set<PropertyKey>) => any;
//# sourceMappingURL=format.d.ts.map