Partager via


IStroke interface

Defines a stroke, i.e. a collection of points that can be rendered on a canvas.

Properties

brush

The brush used to draw the stroke.

clientId

Optional. The id of the client the stroke was created on.

id

The id of the stroke.

length

The number of points in the stroke.

timeStamp

The timestamp when the stroke was created.

Methods

addPoints(IPointerPoint[])

Adds points to the stroke.

deserialize(string)

Deserializes the specified stroke string and sets this stroke's brush, points and other proprties accordingly.

getAllPoints()

Gets a copy of all the points in the stroke.

getBoundingRect()

Computes the stroke's bounding rectangle.

getIntersectionPoints(ISegment)

Computes the intersection points between the stroke and the specified segment.

getPointAt(number)

Gets the point at the given index.

intersectsWithRectangle(IRect)

Determines if the stroke intersects with the specified rectangle.

pointErase(IRect)

Splits this stroke into several other ones by "erasing" the portions that are within the eraser rectangle.

serialize()

Serializes the stroke to a string.

Property Details

brush

The brush used to draw the stroke.

brush: IBrush

Property Value

clientId

Optional. The id of the client the stroke was created on.

clientId?: string

Property Value

string

id

The id of the stroke.

id: string

Property Value

string

length

The number of points in the stroke.

length: number

Property Value

number

timeStamp

The timestamp when the stroke was created.

timeStamp: number

Property Value

number

Method Details

addPoints(IPointerPoint[])

Adds points to the stroke.

function addPoints(points: IPointerPoint[]): boolean

Parameters

points

IPointerPoint[]

The points to add.

Returns

boolean

deserialize(string)

Deserializes the specified stroke string and sets this stroke's brush, points and other proprties accordingly.

function deserialize(serializedStroke: string)

Parameters

serializedStroke

string

The serialized stroke.

getAllPoints()

Gets a copy of all the points in the stroke.

function getAllPoints(): IPointerPoint[]

Returns

getBoundingRect()

Computes the stroke's bounding rectangle.

function getBoundingRect(): IRect

Returns

getIntersectionPoints(ISegment)

Computes the intersection points between the stroke and the specified segment.

function getIntersectionPoints(segment: ISegment): IPoint[]

Parameters

segment
ISegment

The segment to test against.

Returns

IPoint[]

getPointAt(number)

Gets the point at the given index.

function getPointAt(index: number): IPointerPoint

Parameters

index

number

The point index.

Returns

intersectsWithRectangle(IRect)

Determines if the stroke intersects with the specified rectangle.

function intersectsWithRectangle(rectangle: IRect): boolean

Parameters

rectangle
IRect

The rectangle to test against.

Returns

boolean

pointErase(IRect)

Splits this stroke into several other ones by "erasing" the portions that are within the eraser rectangle.

function pointErase(eraserRect: IRect): undefined | IStroke[]

Parameters

eraserRect
IRect

The eraser rectangle.

Returns

undefined | IStroke[]

serialize()

Serializes the stroke to a string.

function serialize(): string

Returns

string