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 { AnyObjectState } from 'features/controlLayers/konva/CanvasObject/types';

export const objectStateNeedsPixelBbox = (state: AnyObjectState): boolean => {
  if (
    state.type === 'eraser_line' ||
    state.type === 'eraser_line_with_pressure' ||
    state.type === 'image' ||
    state.type === 'brush_line' ||
    state.type === 'brush_line_with_pressure' ||
    state.type === 'rect' ||
    state.type === 'oval' ||
    state.type === 'polygon' ||
    state.type === 'lasso' ||
    state.type === 'gradient'
  ) {
    if (state.type === 'image') {
      return state.usePixelBbox !== false;
    }

    if (state.type === 'eraser_line' || state.type === 'eraser_line_with_pressure') {
      return true;
    }

    if (state.type === 'brush_line' || state.type === 'brush_line_with_pressure') {
      return Boolean(state.clip);
    }

    if (state.type === 'rect' || state.type === 'oval') {
      return state.compositeOperation !== 'source-over' || Boolean(state.clip);
    }

    if (state.type === 'polygon' || state.type === 'lasso') {
      return state.compositeOperation !== 'source-over';
    }

    return state.globalCompositeOperation === 'source-atop';
  }

  return false;
};