Interface RestyleableComponent

An interface to be implemented by components with a changable color or TextRenderingStyle.

All such classes must have a member variable, isRestylableComponent that is set to true to allow testing whether the class is a RestylableComponent (see isRestylableComponent).

interface RestyleableComponent {
    contentBBox: Rect2;
    isRestylableComponent: true;
    lastChangedTime: number;
    applyTransformation(affineTransfm): void;
    attachLoadSaveData(key, data): void;
    clone(): AbstractComponent;
    createClone(): AbstractComponent;
    description(localizationTable): string;
    forceStyle(style, editor): void;
    getBBox(): Rect2;
    getExactBBox(): Rect2;
    getId(): string;
    getLoadSaveData(): LoadSaveDataTable;
    getProportionalRenderingTime(): number;
    getSizingMode(): ComponentSizingMode;
    getStyle(): RestyleableComponentStyle;
    getZIndex(): number;
    intersects(lineSegment): boolean;
    intersectsRect(rect): boolean;
    isBackground(): boolean;
    isSelectable(): boolean;
    occludesEverythingBelowWhenRenderedInRect(_visibleRect): boolean;
    onAddToImage(_image): void;
    onRemoveFromImage(): void;
    render(canvas, visibleRect?): void;
    serialize(): {
        data: string | number | any[] | Record<string, any>;
        id: string;
        loadSaveData: LoadSaveDataTable;
        name: string;
        zIndex: number;
    };
    serializeToJSON(): null | string | number | any[] | Record<string, any>;
    setZIndex(newZIndex): SerializableCommand;
    transformBy(affineTransfm): SerializableCommand;
    updateStyle(style): SerializableCommand;
    withRegionErased?(shape, viewport): AbstractComponent[];
}

Hierarchy (view full)

Implemented by

Properties

contentBBox: Rect2

The bounding box of this component. getBBox, by default, returns contentBBox. This must be set by components.

If this changes, EditorImage.queueRerenderOf should be called for this object (provided that this object has been added to the editor.)

Note: This value is ignored if getSizingMode returns FillScreen or FillImage.

isRestylableComponent: true
lastChangedTime: number

The timestamp (milliseconds) at which the component was last changed (i.e. created/translated).

Deprecated

Methods

  • Returns number

    an approximation of the proportional time it takes to render this component. This is intended to be a rough estimate, but, for example, a stroke with two points sould have a renderingWeight approximately twice that of a stroke with one point.

  • Parameters

    Returns boolean

    true if this component intersects rect -- it is entirely contained within the rectangle or one of the rectangle's edges intersects this component.

    The default implementation assumes that this.getExactBBox() returns a tight bounding box -- that any horiziontal/vertical line that intersects this' boounding box also intersects a point in this component. If this is not the case, components must override this function.

  • Renders this component onto the given canvas.

    If visibleRect is given, it should be the region of canvas that is visible -- rendering anything outside of visibleRect should have no visible effect on the resultant image.

    For optimal performance, implementers should call canvas.startObject and canvas.endObject before and after rendering.

    Parameters

    Returns void

  • Convert the component to an object that can be passed to JSON.stringify.

    Do not rely on the output of this function to take a particular form — this function's output can change form without a major version increase.

    Returns {
        data: string | number | any[] | Record<string, any>;
        id: string;
        loadSaveData: LoadSaveDataTable;
        name: string;
        zIndex: number;
    }

    • data: string | number | any[] | Record<string, any>
    • id: string
    • loadSaveData: LoadSaveDataTable
    • name: string
    • zIndex: number

Generated using TypeDoc

OpenSource licenses