@zsnout/ithkuil
Version:
A set of tools which can generate and parse romanized Ithkuil text and which can generate Ithkuil script from text and JSON data.
28 lines (27 loc) • 852 B
JavaScript
import { jsx as _jsx } from "@zsnout/ithkuil-jsx/jsx-runtime";
import { Point } from "./point.js";
/**
* Gets a point on an SVG path.
*
* @param path The path to get the origin of.
* @param offset The distance along the path to get the point on.
* @returns The point on `path` at the specified offset.
*/
export function getOrigin(path, offset = 0) {
const el = (_jsx("path", { d: path }));
return el.getPointAtLength(offset);
}
/**
* Shows the origin of an SVG path.
*
* @param props Properties modifying the display.
* @returns A point showing the origin of the specified path.
*/
export function Origin(props) {
const d = props.children.getAttribute("d");
if (!d) {
return (_jsx("path", {}));
}
const origin = getOrigin(d, props.offset);
return (_jsx(Point, { ...props, x: origin.x, y: origin.y }));
}