Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

939 B
Raw Blame
/** Pure document-space SVG path builders feed injected Path2D creation for selection commits and node tests. */

import type { Rect } from '@workbench/canvas-engine/types';

export const rectPathData = (r: Rect): string =>
  `M ${r.x} ${r.y} L ${r.x + r.width} ${r.y} L ${r.x + r.width} ${r.y + r.height} L ${r.x} ${r.y + r.height} Z`;

/** Exact ellipse from two half-arcs; a single closed arc would have coincident endpoints and be dropped. */
export const ellipsePathData = (r: Rect): string => {
  const rx = r.width / 2;
  const ry = r.height / 2;
  const cy = r.y + ry;
  const left = r.x;
  const right = r.x + r.width;
  return `M ${left} ${cy} A ${rx} ${ry} 0 1 0 ${right} ${cy} A ${rx} ${ry} 0 1 0 ${left} ${cy} Z`;
};

/** SVG path data for `kind` inscribed in `rect`. */
export const selectionShapePathData = (kind: 'rect' | 'ellipse', rect: Rect): string =>
  kind === 'ellipse' ? ellipsePathData(rect) : rectPathData(rect);