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. |
client |
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. |
time |
The timestamp when the stroke was created. |
Methods
add |
Adds points to the stroke. |
deserialize(string) | Deserializes the specified stroke string and sets this stroke's brush, points and other proprties accordingly. |
get |
Gets a copy of all the points in the stroke. |
get |
Computes the stroke's bounding rectangle. |
get |
Computes the intersection points between the stroke and the specified segment. |
get |
Gets the point at the given index. |
intersects |
Determines if the stroke intersects with the specified rectangle. |
point |
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
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
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()
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
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour