Skip to main content

IShape

Interface representing a shape that can be rendered on a canvas.

This interface defines methods for rendering the shape on a canvas and managing observers.

Accessors

state

get state(): ShapeState

Gets the current state of the shape.

set state(state): void

Sets a new state for the shape.

Parameters

state: ShapeState

The new state to assign to the shape.

Returns

ShapeState

The current state of the shape.

Defined in

shapes/IShape.ts:67


stateStyle

get stateStyle(): IShapeStyle

Retrieves the effective style of the shape based on its current state.

Returns

IShapeStyle

The computed style object for the current shape state, with state-specific overrides merged in as necessary.

Defined in

shapes/IShape.ts:81

Methods

addObserver()

addObserver(observer): void

Adds an observer function that will be called when the shape undergoes changes.

Parameters

observer

A callback function to be invoked when the shape's state changes.

Returns

void

Defined in

shapes/IShape.ts:23


hide()

hide(): void

Hides the shape, preventing it from being rendered on the canvas. The shape will still exist and retain its properties, but it will not appear during rendering until show() is called.

Returns

void

Defined in

shapes/IShape.ts:44


isMouseOver()

isMouseOver(mousePosition): boolean

Determines if the mouse is currently over the shape.

Parameters

mousePosition: Point

The current mouse position.

Returns

boolean

True if the mouse is over the shape, false otherwise.

Defined in

shapes/IShape.ts:60


isVisible()

isVisible(): boolean

Checks whether the shape is currently visible.

Returns

boolean

Returns true if the shape is visible and will be rendered on the canvas. Returns false if the shape is hidden and will not be rendered.

Defined in

shapes/IShape.ts:52


removeObserver()

removeObserver(observer): void

Removes an observer function that was previously added.

Parameters

observer

The observer callback function to be removed.

Returns

void

Defined in

shapes/IShape.ts:30


render()

render(context): void

Renders the shape to a given canvas context.

Parameters

context: CanvasRenderingContext2D

The 2D rendering context of the canvas where the shape will be drawn.

Returns

void

Defined in

shapes/IShape.ts:16


show()

show(): void

Makes the shape visible, allowing it to be rendered on the canvas. If the shape was previously hidden, calling this method will make it appear during the next rendering cycle.

Returns

void

Defined in

shapes/IShape.ts:37