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.

654 B
Raw Blame
/** Commit-time modifiers override the persistent selection-op mode, consistently across lasso and marquee. */

import type { PointerModifiers, SelectionOp } from '@workbench/canvas-engine/types';

/**
 * Resolves the boolean op for a commit: held modifiers win over the persistent `mode`. shift = add, alt = subtract,
 * shift+alt = intersect.
 */
export const selectionOpFor = (modifiers: Pick<PointerModifiers, 'shift' | 'alt'>, mode: SelectionOp): SelectionOp => {
  if (modifiers.shift && modifiers.alt) {
    return 'intersect';
  }
  if (modifiers.shift) {
    return 'add';
  }
  if (modifiers.alt) {
    return 'subtract';
  }
  return mode;
};