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.

1.2 KB
Raw Blame
import type { OverlayState } from './render/overlayRenderer';
import type { RasterSurface } from './render/raster';

import { VectorEditingController } from './controllers/vectorEditingController';
import { traceVectorLayer } from './controllers/vectorTraceController';
import { createVectorLayer, nextVectorLayerName } from './document/vectorLayerFactories';
import { drawVectorEditOverlay } from './render/vectorEditOverlay';
import { drawVectorGuides } from './render/vectorGuides';
import { createVectorShapeTool } from './tools/vectorShapeTool';

/** Vector controllers, tools and rendering share the engine lifetime. */
export const createVectorRuntime = (options: ConstructorParameters<typeof VectorEditingController>[0]) => ({
  editor: new VectorEditingController(options),
  shape: createVectorShapeTool(),
  createLayer: createVectorLayer,
  nextLayerName: nextVectorLayerName,
  trace: traceVectorLayer,
  render: (ctx: RasterSurface['ctx'], state: OverlayState): void => {
    drawVectorGuides(ctx, state.view, state.vectorGuides ?? [], state.vectorShapePreview ?? null);
    drawVectorEditOverlay(ctx, state.view, state.vectorEdit ?? null);
  },
});

export type VectorRuntime = ReturnType<typeof createVectorRuntime>;