Blockbench Reference Docs
    Preparing search index...

    Interface BrushOptions

    interface BrushOptions {
        blend_modes: boolean;
        floor_coordinates: boolean | (() => boolean);
        offset_even_radius: boolean;
        opacity: boolean;
        shapes: boolean;
        size: boolean;
        softness: boolean;
        changePixel(
            pixel_x: number,
            pixel_y: number,
            pixel_color: RGBAColor,
            local_opacity: number,
            PaintContext: PaintContext,
        ): RGBAColor;
        draw(
            context: {
                ctx: CanvasRenderingContext2D;
                event: PointerEvent;
                size: number;
                softness: number;
                texture: Texture;
                x: number;
                y: number;
            },
        ): void;
        onStrokeEnd(
            context: {
                raycast_data: RaycastResult;
                texture: Texture;
                uv?: any;
                x: number;
                y: number;
            },
        ): void;
        onStrokeMove(
            context: {
                event: PointerEvent;
                raycast_data: RaycastResult;
                texture: Texture;
                uv?: any;
                x: number;
                y: number;
            },
        ): boolean;
        onStrokeStart(
            context: {
                event: PointerEvent;
                raycast_data: RaycastResult;
                texture: Texture;
                uv?: any;
                x: number;
                y: number;
            },
        ): boolean;
    }
    Index

    Properties

    blend_modes: boolean

    Enable the input for blend modes when this tool is selected

    floor_coordinates: boolean | (() => boolean)

    Set whether the brush coordinates get floored to snap to the nearest pixel.

    offset_even_radius: boolean

    When the brush size is an even number, offset the snapping by half a pixel so that even size brush strokes can be correctly centered

    opacity: boolean

    Enable the input for opacity when this tool is selected

    shapes: boolean

    Enable the input for shapes when this tool is selected

    size: boolean

    Enable the input for brush size when this tool is selected

    softness: boolean

    Enable the input for softness when this tool is selected

    Methods

    • Function that runs per pixel when the brush is used. Mutually exclusive with draw().

      Parameters

      • pixel_x: number

        Local X coordinate relative to the brush center

      • pixel_y: number

        Local Y coordinate relative to the brush center

      • pixel_color: RGBAColor

        Current color of the pixel on the texture

      • local_opacity: number

        Local opacity of the current pixel on the brush, between 0 and 1. Opacity falls of to the sides of the brush if the brush is set to smooth. Opacity from the Opacity slider is not factored in yet.

      • PaintContext: PaintContext

        Additional context to the paint stroke

      Returns RGBAColor

    • Alternative way to create a custom brush, mutually exclusive with the changePixel() function. Draw runs once every time the brush starts or moves, and also along the bath on lines.

      Parameters

      • context: {
            ctx: CanvasRenderingContext2D;
            event: PointerEvent;
            size: number;
            softness: number;
            texture: Texture;
            x: number;
            y: number;
        }

      Returns void

    • Function that runs when a new brush stroke starts.

      Parameters

      • context: {
            raycast_data: RaycastResult;
            texture: Texture;
            uv?: any;
            x: number;
            y: number;
        }

      Returns void

    • Function that runs when a new brush stroke starts. Return false to cancel the brush stroke

      Parameters

      • context: {
            event: PointerEvent;
            raycast_data: RaycastResult;
            texture: Texture;
            uv?: any;
            x: number;
            y: number;
        }

      Returns boolean

    • Function that runs when a new brush stroke starts. Return false to cancel the brush stroke

      Parameters

      • context: {
            event: PointerEvent;
            raycast_data: RaycastResult;
            texture: Texture;
            uv?: any;
            x: number;
            y: number;
        }

      Returns boolean