Pixen JavaScript API
    Preparing search index...

    Interface Selection

    Pixel selection state and selection editing commands.

    interface Selection {
        exists: boolean;
        canReselect: boolean;
        frame: Rect | null;
        contains(point: Point): boolean;
        selectAll(): void;
        selectVisiblePixels(): void;
        deselect(): void;
        invert(): void;
        reselect(): void;
        addPixel(point: Point): void;
        removePixel(point: Point): void;
        addRect(rect: Rect): void;
        removeRect(rect: Rect): void;
        translate(x: number, y: number): void;
        flip(direction: FlipDirection): void;
        rotate(degrees: number): void;
        deleteContents(): void;
        cropCanvas(): void;
        promoteToLayer(): Layer | null;
    }
    Index
    exists: boolean

    Whether any pixels are currently selected.

    canReselect: boolean

    Whether the previous selection can be restored.

    frame: Rect | null

    The selected pixel bounds, or null when there is no selection.

    • Tests whether a selected pixel contains a point.

      Parameters

      • point: Point

        An integer pixel coordinate.

      Returns boolean

      Whether the point is on-canvas and selected.

    • Selects every pixel.

      Returns void

    • Selects pixels that are visible in the composited canvas.

      Returns void

    • Clears the current selection while retaining it for reselect().

      Returns void

    • Inverts selected and unselected pixels.

      Returns void

    • Restores the most recently deselected selection.

      Returns void

    • Parameters

      • point: Point

        Pixel coordinate to add to the selection.

      Returns void

    • Parameters

      • point: Point

        Pixel coordinate to remove from the selection.

      Returns void

    • Parameters

      • rect: Rect

        Pixel rectangle to add to the selection.

      Returns void

    • Parameters

      • rect: Rect

        Pixel rectangle to remove from the selection.

      Returns void

    • Translates the selection mask.

      Parameters

      • x: number

        Horizontal pixel delta.

      • y: number

        Vertical pixel delta.

      Returns void

    • Parameters

      • degrees: number

        Clockwise rotation in multiples of 90 degrees.

      Returns void

    • Deletes selected pixels from the active layer.

      Returns void

    • Crops the canvas to the selection bounds.

      Returns void

    • Returns Layer | null

      A new layer containing the selected pixels, or null without a selection.