VectorObject

A VectorObject is a vector object that can be drawn on a vector graphics canvas.

Constructor

new VectorObject(path, fill, fill_rule, stroke, stroke_width, stroke_line_cap, stroke_line_join, stroke_miter_limit, stroke_dash_offset, stroke_dash_array, children, name, transform)

Creates a new VectorObject.

Parameters:
NameTypeDescription
pathPath2D

The Path2D of the vector object.

fillStyle

The fill Style of the vector object.

fill_rulestring

The fill rule of the vector object.

strokeStyle

The stroke Style of the vector object.

stroke_widthnumber

The stroke width of the vector object.

stroke_line_capstring

The stroke line cap of the vector object.

stroke_line_joinstring

The stroke line join of the vector object.

stroke_miter_limitnumber

The stroke miter limit of the vector object.

stroke_dash_offsetnumber

The stroke dash offset of the vector object.

stroke_dash_arrayArray.<number>

The stroke dash array of the vector object.

childrenArray.<VectorObject>

The children of the vector object.

namestring | null | undefined

The name of the vector object.

transformTransformationMatrix

The TransformationMatrix of the vector object.

Classes

VectorObject

Members

actual_path

Gets the Path2D with the applied TransformationMatrix.

center

Gets the center Point2D of the VectorObject.

children

Gets the children of the VectorObject.

fill

Gets the fill Style of the VectorObject.

fill_rule

Gets the fill rule of the VectorObject.

height

Gets the height of the VectorObject.

is_closed

Gets whether the VectorObject's path is closed.

name

Gets the name of the VectorObject.

num_children

Gets the number of children in the VectorObject.

num_curves

Gets the number of cubic bezier curves in the vector object.

num_points

Gets the number of points in the VectorObject's path.

path

Gets the Path2D of the VectorObject.

stroke

Gets the stroke Style of the VectorObject.

stroke_dash_array

Gets the stroke dash array of the VectorObject.

stroke_dash_offset

Gets the stroke dash offset of the VectorObject.

stroke_line_cap

Gets the stroke line cap of the VectorObject.

stroke_line_join

Gets the stroke line join of the VectorObject.

stroke_miter_limit

Gets the stroke miter limit of VectorObject.

stroke_width

Gets the stroke width of the VectorObject.

subpaths

Gets the subpaths of the VectorObject.

transform

Gets the transformation matrix of the VectorObject.

width

Gets the width of the VectorObject.

Methods

bounding_box(recursiveopt) → {BoundingBox|undefined}

Gets the BoundingBox of the VectorObject.

Parameters:
NameTypeAttributesDescription
recursiveboolean | null<optional>

Whether to include the children of the vector object.

Returns:

The bounding box of the vector object.

Type: 
BoundingBox | undefined

clone() → {VectorObject}

Clones the vector object.

Returns:

The cloned vector object.

Type: 
VectorObject

get_children_by_names(names) → {Array.<VectorObject>}

Gets the children of the VectorObject with the given names.

Parameters:
NameTypeDescription
namesArray.<string>

The names of the children to get.

Returns:

The children with the given names.

Type: 
Array.<VectorObject>

get_children_recursive(with_pointsopt) → {Array.<VectorObject>}

Gets the children of the VectorObject recursively.

Parameters:
NameTypeAttributesDescription
with_pointsboolean | null<optional>

Whether to include the children of the children of the vector object, default is false.

Returns:

The children of the vector object.

Type: 
Array.<VectorObject>

get_critical_point(key_x, key_y, recursiveopt) → {Point2D|undefined}

Gets the critical Point2D of the VectorObject.

Parameters:
NameTypeAttributesDescription
key_xnumber

The x key of the critical point. If negative, the minimum x is returned. If positive, the maximum x is returned. If zero, the center x is returned.

key_ynumber

The y key of the critical point. If negative, the minimum y is returned. If positive, the maximum y is returned. If zero, the center y is returned.

recursiveboolean | null<optional>

Whether to include the children of the vector object.

Returns:

The critical point of the vector object.

Type: 
Point2D | undefined

slice_children(start, end) → {Array.<VectorObject>}

Slices the VectorObject's children.

Parameters:
NameTypeDescription
startnumber

The start index of the children to slice.

endnumber

The end index of the children to slice.

Returns:

The sliced children of the vector object.

Type: 
Array.<VectorObject>

(static) default_vector_object() → {VectorObject}

Creates a new empty VectorObject.

Returns:

A new empty vector object.

Type: 
VectorObject