Skip to main content

Circle

Class representing a circle, extending the Shape class with a CircleDefinition. Provides functionality for rendering, resizing and moving the circle.

Extends​

Constructors​

new Circle()​

new Circle(center, radius, style?, options?): Circle

Creates an instance of the Circle class.

The Circle can be created either by passing a Point object representing the center, or by providing the individual coordinates for the center.

Parameters​

• center: Point

The center Point of the circle.

• radius: number

The radius of the circle.

• style?: ICircleStyle

Defines the styling of the circle.

• options?: ICircleOptions

The configuration options for the circle.

Returns​

Circle

Throws​

InvalidConstructorArgumentsError if invalid arguments are passed.

Overrides​

Shape.constructor

Defined in​

shapes/Circle.ts:21

new Circle()​

new Circle(centerX, centerY, radius, style?, options?): Circle

Creates an instance of the Circle class.

The Circle can be created either by passing a Point object representing the center, or by providing the individual coordinates for the center.

Parameters​

• centerX: number

The X-coordinate of the starting point.

• centerY: number

The Y-coordinate of the starting point.

• radius: number

The radius of the circle.

• style?: ICircleStyle

Defines the styling of the circle.

• options?: ICircleOptions

The configuration options for the circle.

Returns​

Circle

Throws​

InvalidConstructorArgumentsError if invalid arguments are passed.

Overrides​

Shape<CircleDefinition, CircleStyle, CircleOptions>.constructor

Defined in​

shapes/Circle.ts:30

Properties​

_definition​

protected _definition: CircleDefinition

The shape definition, proxied to trigger observer notifications on change.

Inherited from​

Shape._definition

Defined in​

shapes/Shape.ts:22


_options​

protected _options: CircleOptions

The options for configuring the shape, proxied to trigger observer notifications on change.

Inherited from​

Shape._options

Defined in​

shapes/Shape.ts:28


_state​

protected _state: ShapeState = ShapeState.Default

The current state of the shape, representing its visual or interactive status.

Inherited from​

Shape._state

Defined in​

shapes/Shape.ts:31


_style​

protected _style: CircleStyle

The style settings for the shape, proxied to trigger observer notifications on change.

Inherited from​

Shape._style

Defined in​

shapes/Shape.ts:25


observers​

protected observers: () => void[] = []

List of observer functions to be notified on shape changes.

Inherited from​

Shape.observers

Defined in​

shapes/Shape.ts:34

Accessors​

center​

Get Signature​

get center(): Point

Gets the center point of the circle.

Returns​

Point

The center point of the circle.

Set Signature​

set center(center): void

Sets the center point of the circle.

Parameters​

• center: Point

The new center point of the circle.

Returns​

void

Defined in​

shapes/Circle.ts:78


options​

Get Signature​

get options(): TOptions

Gets the configuration options of the shape.

Returns​

TOptions

The current options.

Set Signature​

set options(options): void

Updates the configuration options of the shape and notifies observers.

Parameters​

• options: TOptions

The new options to apply.

Returns​

void

Inherited from​

Shape.options

Defined in​

shapes/Shape.ts:220


radius​

Get Signature​

get radius(): number

Gets the radius of the circle.

Returns​

number

The radius of the circle.

Set Signature​

set radius(radius): void

Sets the radius of the circle.

Parameters​

• radius: number

The new radius of the circle.

Returns​

void

Defined in​

shapes/Circle.ts:87


state​

Get Signature​

get state(): ShapeState

Gets the current state of the shape.

Returns​

ShapeState

The current state of the shape.

Set Signature​

set state(state): void

Sets a new state for the shape.

Parameters​

• state: ShapeState

The new state to assign to the shape.

Returns​

void

Inherited from​

Shape.state

Defined in​

shapes/Shape.ts:238


stateStyle​

Get Signature​

get stateStyle(): TStyle

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

Returns​

TStyle

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

Inherited from​

Shape.stateStyle

Defined in​

shapes/Shape.ts:260


style​

Get Signature​

get style(): TStyle

Gets the style settings of the shape.

Returns​

TStyle

The current style settings.

Set Signature​

set style(style): void

Updates the style settings of the shape and notifies observers.

Parameters​

• style: TStyle

The new style settings to apply.

Returns​

void

Inherited from​

Shape.style

Defined in​

shapes/Shape.ts:202

Methods​

addObserver()​

addObserver(observer): void

Adds an observer function that will be called when the shape's state changes.

Parameters​

• observer

The observer callback function.

Returns​

void

Inherited from​

Shape.addObserver

Defined in​

shapes/Shape.ts:171


hasBorder()​

protected hasBorder(): boolean

Determines if the current state style includes a visible border.

Returns​

boolean

true if borderColor and borderWidth are defined and indicate a visible border; otherwise, false.

Inherited from​

Shape.hasBorder

Defined in​

shapes/Shape.ts:297


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

Inherited from​

Shape.hide

Defined in​

shapes/Shape.ts:127


isDraggable()​

isDraggable(): boolean

Checks whether the shape is draggable or not.

Returns​

boolean

Returns true if the shape is draggable. Returns false if the shape is not draggable.

Inherited from​

Shape.isDraggable

Defined in​

shapes/Shape.ts:147


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.

Overrides​

Shape.isMouseOver

Defined in​

shapes/Circle.ts:170


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.

Inherited from​

Shape.isVisible

Defined in​

shapes/Shape.ts:137


move()​

move(deltaX, deltaY): void

Moves the circle by adjusting the current center by delta values.

Parameters​

• deltaX: number = 0

The change in the x-coordinate.

• deltaY: number = 0

The change in the y-coordinate.

Returns​

void

Defined in​

shapes/Circle.ts:117


onDrag()​

onDrag(delta): void

Handles the drag operation by applying the given delta to the current position.

Parameters​

• delta: Point

The change in position represented as a Point.

Returns​

void

Overrides​

Shape.onDrag

Defined in​

shapes/Circle.ts:188


removeObserver()​

removeObserver(observer): void

Removes a previously added observer function.

Parameters​

• observer

The observer callback function to be removed.

Returns​

void

Inherited from​

Shape.removeObserver

Defined in​

shapes/Shape.ts:182


render()​

render(context): void

Renders the circle on the canvas using the provided 2D rendering context.

The circle will be rendered with its current position and radius size.

Parameters​

• context: CanvasRenderingContext2D

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

Returns​

void

Overrides​

Shape.render

Defined in​

shapes/Circle.ts:137


resize()​

resize(delta): void

Resizes the circle by adjusting the current radius by delta values.

Parameters​

• delta: number

The change of the radius.

Returns​

void

Defined in​

shapes/Circle.ts:126


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

Inherited from​

Shape.show

Defined in​

shapes/Shape.ts:118


toArray()​

toArray(): any[]

Converts the shape's definition to an array.

Returns​

any[]

An array representation of the shape's definition.

Inherited from​

Shape.toArray

Defined in​

shapes/Shape.ts:100


toJson()​

toJson(): string

Converts the shape's definition to a JSON string.

Returns​

string

A JSON string representation of the shape's definition.

Inherited from​

Shape.toJson

Defined in​

shapes/Shape.ts:109