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.

885 B
Raw Blame
/**
 * Eraser binds shared paint gestures to destination-out with eraser size/opacity and no color. Pen pressure may thin
 * the width like the brush; it never modulates erase strength. Gesture state is per engine.
 */

import { PRESSURE_THINNING } from '@workbench/canvas-engine/tools/paintConstants';
import { createPaintTool } from '@workbench/canvas-engine/tools/paintTool';

import type { Tool } from './tool';

export const createEraserTool = (): Tool =>
  createPaintTool({
    color: () => '#000000',
    composite: 'destination-out',
    id: 'eraser',
    hardness: (ctx) => ctx.stores.eraserOptions.get().hardness,
    opacity: (ctx) => ctx.stores.eraserOptions.get().opacity,
    pressureOpacity: () => false,
    size: (ctx) => ctx.stores.eraserOptions.get().size,
    thinning: (ctx) => (ctx.stores.eraserOptions.get().pressureAffectsWidth ? PRESSURE_THINNING : 0),
  });