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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import type { PanZoomPoint } from '@workbench/panZoom';
/** Share pointer tracking between stage and comparison loupes; each uses its own zoom coordinate space. */
/** Reset on the first touch or mouse press to discard pointers whose releases were missed before arming a pinch. */
export const trackPointerDown = (
pointers: Map<number, PanZoomPoint>,
event: { clientX: number; clientY: number; isPrimary: boolean; pointerId: number }
): [number, number] | null => {
if (event.isPrimary) {
pointers.clear();
}
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size !== 2) {
return null;
}
const [first, second] = [...pointers.keys()];
return [first!, second!];
};
/** Tolerates capture failure on released pointers; uncaptured gestures work on the surface. */
export const capturePointer = (element: Element, pointerId: number): void => {
try {
element.setPointerCapture(pointerId);
} catch {
// Pointer ended before the gesture could claim it.
}
};
export const releasePointer = (element: Element, pointerId: number): void => {
if (element.hasPointerCapture(pointerId)) {
element.releasePointerCapture(pointerId);
}
};