48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
|
|
export type SelectionType = 'rectangular' | 'elliptical' | 'lasso' | 'magic-wand';
|
||
|
|
|
||
|
|
export type SelectionMode = 'new' | 'add' | 'subtract' | 'intersect';
|
||
|
|
|
||
|
|
export interface SelectionBounds {
|
||
|
|
x: number;
|
||
|
|
y: number;
|
||
|
|
width: number;
|
||
|
|
height: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Selection mask is a 2D boolean array representing selected pixels
|
||
|
|
* true = selected, false = not selected
|
||
|
|
*/
|
||
|
|
export interface SelectionMask {
|
||
|
|
width: number;
|
||
|
|
height: number;
|
||
|
|
data: Uint8Array; // 1 byte per pixel (0 = not selected, 255 = selected)
|
||
|
|
bounds: SelectionBounds;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface Selection {
|
||
|
|
id: string;
|
||
|
|
layerId: string;
|
||
|
|
mask: SelectionMask;
|
||
|
|
inverted: boolean;
|
||
|
|
feather: number; // Feather radius in pixels
|
||
|
|
createdAt: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface SelectionState {
|
||
|
|
activeSelection: Selection | null;
|
||
|
|
selectionType: SelectionType;
|
||
|
|
selectionMode: SelectionMode;
|
||
|
|
feather: number;
|
||
|
|
tolerance: number; // For magic wand (0-255)
|
||
|
|
isMarching: boolean; // Marching ants animation
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Point for lasso selection
|
||
|
|
*/
|
||
|
|
export interface LassoPoint {
|
||
|
|
x: number;
|
||
|
|
y: number;
|
||
|
|
}
|