import { Canvas, IdxsByPath, InputInfo, Num, Shape } from "@penrose/core"; import { SharedInput } from "./builder.js"; import { DragConstraint } from "./types.js"; /** Data passed into `create` */ export type DiagramCreationData = { canvas: Canvas; variation: string; inputs: InputInfo[]; constraints: Num[]; objectives: Num[]; shapes: Shape[]; nameShapeMap: Map>; namedInputs: Map; pinnedInputs: Set; draggingConstraints: Map; inputIdxsByPath: IdxsByPath; lassoStrength: number; sharedInputs: Set; interactiveOnlyShapes: Set>; eventListeners: Map void][]>; }; /** * A renderable diagram, created with `DiagramBuilder.prototype.build`. * You should pass a factory method to `useDiagram` to create a `Diagram` from * within a React component, for performance reasons. */ export declare class Diagram { private state; /** * Manually pinned indices (during construction or at runtime). These will remain * pinned until unpinned manually. * @private */ private manuallyPinnedIndices; /** * Map from shape ids to translatable inputs who have been temporarily pinned. These will be * unpinned after the drag ends, were manually pinned as well. * @private */ private tempPinnedForDrag; private draggingConstraints; private namedInputs; private onInteraction; private inputEffects; private lassoEnabled; private sharedInputs; private interactiveOnlyShapes; private eventListeners; private optimizationLooper; private renderLooper; private onOptimizationFinished; private onOptimizationStepped; private onOptimizationStarted; private readonly namespace; /** * Create a new renderable diagram. This should not be called directly; use * `DiagramBuilder.prototype.build` instead. * @param data */ static create: (data: DiagramCreationData) => Promise; private constructor(); /** * Render an SVG of the current diagram state and a map of shape names to SVG elements. */ render: () => Promise<{ svg: SVGSVGElement; nameElemMap: Map; }>; /** * */ renderStatic: () => Promise; /** * Take one optimization step. This will update the internal state of the diagram. * @returns `true` if the optimization should continue, `false` if it should stop * (i.e. when optimization converges or fails) */ optimizationStep: () => Promise; private copyNonLassoVaryingVals; private initialRender; private copyAttrs; /** * Returns an HTMLElement presenting an interactive diagram. This element should * be appended added to an existing document node to be visible. The element is * styled by default with "width: 100%; height: 100%l touch-action: none". */ getInteractiveElement: () => HTMLDivElement; beginDrag: (name: string) => void; endDrag: (name: string) => void; translate: (name: string, dx: number, dy: number) => void; /** * Get the value of an input by name. * @param name The name of the input */ getInput: (name: string) => number; /** * Set the value of an input by name. * @param name The name of the input * @param val The new value */ setInput: (name: string, val: number) => void; /** * Get the value of an input by index. * @param idx The index of the input */ getOptimized: (name: string) => boolean; /** * Set the value of an input by index. * @param idx The index of the input * @param optimized Whether the input should be optimized */ setOptimized: (name: string, optimized: boolean) => void; /** * Get the canvas of the diagram. */ getCanvas: () => { width: number; height: number; size: [number, number]; xRange: [number, number]; yRange: [number, number]; }; /** * Get the dragging constraints of the diagram. */ getDraggingConstraints: () => Map; setOnInteraction: (fn: () => void) => () => void; /** * Add an effect to an input. The effect will be called any time the input changes. * @param name The name of the input * @param fn The effect function */ addInputEffect: (name: string, fn: (val: number, name: string) => void) => void; setOnOptimizationFinished: (fn: (xs: number[]) => void) => void; setOnOptimizationStepped: (fn: (xs: number[]) => void) => void; setOnOptimizationStarted: (fn: (xs: number[]) => void) => void; /** * Remove an effect from an input. * @param name The name of the input * @param fn The effect function */ removeInputEffect: (name: string, fn: (val: number, name: string) => void) => void; discard: () => void; private setAndEnableLasso; private triggerInputEffects; private resetOptimization; private applyPins; private static makeState; } //# sourceMappingURL=diagram.d.ts.map