VectorObjectBuilder

A VectorObjectBuilder can be used to build a VectorObject with operations.

Constructor

new VectorObjectBuilder(vector_object)

Creates a new VectorObjectBuilder from a VectorObject.

Parameters:
NameTypeDescription
vector_objectVectorObject

The vector object to start building on.

Classes

VectorObjectBuilder

Methods

actual_path_as_path(untransformopt, recursiveopt) → {VectorObjectBuilder}

Applies the current transformation to the path of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
untransformboolean | null<optional>

Whether to remove transformations after applying the current transformation to the path, default is true.

recursiveboolean | null<optional>

Whether to apply the actual path as path operation to the children of the vector object, default is true.

Returns:

The vector object being built with the apply transformation operation.

Type: 
VectorObjectBuilder

add_child(child) → {VectorObjectBuilder}

Adds a child to the VectorObjectBuilder.

Parameters:
NameTypeDescription
childVectorObjectBuilder

The child to add to the vector object.

Returns:

The vector object being built with the add child operation.

Type: 
VectorObjectBuilder

add_children(children) → {VectorObjectBuilder}

Adds a child to the VectorObjectBuilder.

Parameters:
NameTypeDescription
childrenArray.<VectorObjectBuilder>

The children to add at the end of the vector object.

Returns:

The vector object being built with the add children operation.

Type: 
VectorObjectBuilder

apply_transform(matrix, recursiveopt) → {VectorObjectBuilder}

Applies the TransformationMatrix to the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
matrixTransformationMatrix

The matrix in CSS format to apply to the vector object.

recursiveboolean | null<optional>

Whether to apply the apply transform operation to the children of the vector object, default is true.

Returns:

The vector object being built with the apply transform operation.

Type: 
VectorObjectBuilder

arrange_children(directionopt, buffopt, aligned_edgeopt, centeropt, recursiveopt) → {VectorObjectBuilder}

Arranges the children of the VectorObjectBuilder in the given direction, with a buff distance between them and aligning at the given edge.

Parameters:
NameTypeAttributesDescription
directionPoint2D | null<optional>

The direction to arrange the children. If not given, the children will be arranged horizontally in the positive x direction.

buffnumber | null<optional>

The buffer to leave between the children. If not given, the children will be touching, default is 0.

aligned_edgePoint2D | null<optional>

The edge of the children to align with the point. If not given, the children will be aligned at the middle.

centerPoint2D | null<optional>

The center of the children. If not given, the children won't be centered at any point.

recursiveboolean | null<optional>

Whether to apply the arrange subobjects operation to the children of the vector object, default is true.

Returns:

The vector object being built with the arrange subobjects operation.

Type: 
VectorObjectBuilder

become_partial(start, end, samplesopt, extra_lengthopt, recursiveopt) → {VectorObjectBuilder}

Trims the stroke of the VectorObjectBuilder to the given start and end proportions.

Parameters:
NameTypeAttributesDescription
startnumber

The proportion of the path to start at.

endnumber

The proportion of the path to end at.

samplesnumber | null<optional>

Number of samples to compute the length of each cubic bezier curve segment.

extra_lengthnumber | null<optional>

Extra length to add to each length computation to ensure the path is not too short.

recursiveboolean | null<optional>

Whether to apply the become partial operation to the children of the vector object, default is true

Returns:

The vector object being built with the become partial operation.

Type: 
VectorObjectBuilder

bezier_curve_to(p1, p2, p3) → {VectorObjectBuilder}

Draws a cubic bezier curve from the current drawing point with the given control Point2Ds and end Point2D.

Parameters:
NameTypeDescription
p1Point2D

The first control point of the bezier curve.

p2Point2D

The second control point of the bezier curve.

p3Point2D

The end point of the bezier curve.

Returns:

The vector object being built with the bezier curve to operation.

Type: 
VectorObjectBuilder

build() → {VectorObject}

Builds the VectorObject by applying sequentially all the operations to the VectorObjectBuilder.

Returns:

The vector object built by applying the operations to it.

Type: 
VectorObject

clone() → {VectorObjectBuilder}

Clones the VectorObjectBuilder.

Returns:

A clone of the vector object builder.

Type: 
VectorObjectBuilder

close() → {VectorObjectBuilder}

Closes the current subpath of the VectorObjectBuilder.

Returns:

The vector object being built with the close operation.

Type: 
VectorObjectBuilder

fade_fill(factor, recursiveopt) → {VectorObjectBuilder}

Fades fill's opacity of the VectorObjectBuilder by the given factor.

Parameters:
NameTypeAttributesDescription
factornumber

The factor to fade the fill style by.

recursiveboolean | null<optional>

Whether to apply the fade fill operation to the children of the vector object.

Returns:

The vector object being built with the fade fill operation.

Type: 
VectorObjectBuilder

fade_stroke(factor, recursiveopt) → {VectorObjectBuilder}

Fades stroke's opacity of the VectorObjectBuilder by the given factor.

Parameters:
NameTypeAttributesDescription
factornumber

The factor to fade the stroke style by.

recursiveboolean | null<optional>

Whether to apply the fade stroke operation to the children of the vector object.

Returns:

The vector object being built with the fade stroke operation.

Type: 
VectorObjectBuilder

insert_child(index, child) → {VectorObjectBuilder}

Inserts a child into the VectorObjectBuilder at the given index.

Parameters:
NameTypeDescription
indexnumber

The index to insert the child at.

childVectorObjectBuilder

The child to insert into the vector object.

Returns:

The vector object being built with the insert child operation.

Type: 
VectorObjectBuilder

insert_children(index, children) → {VectorObjectBuilder}

Inserts children into the VectorObjectBuilder at the given index.

Parameters:
NameTypeDescription
indexnumber

The index to insert the children at.

childrenArray.<VectorObjectBuilder>

The children to insert into the vector object.

Returns:

The vector object being built with the insert children operation.

Type: 
VectorObjectBuilder

lerp_fill(fill, t, xopt, yopt, widthopt, heightopt, data_widthopt, data_heightopt, recursiveopt) → {VectorObjectBuilder}

Linearly interpolates the fill Style of the VectorObjectBuilder with another VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
fillStyle

The vector object to interpolate the fill style with.

tnumber

The factor to interpolate the fill style by.

xnumber | null<optional>

The image's top left corner x-coordinate. It must be provided if the fill style contains an image or different kinds of gradients.

ynumber | null<optional>

The image's top left corner y-coordinate. It must be provided if the fill style contains an image or different kinds of gradients.

widthnumber | null<optional>

The image's rendering width. It must be provided if the fill style contains an image or different kinds of gradients.

heightnumber | null<optional>

The image's rendering height. It must be provided if the fill style contains an image or different kinds of gradients.

data_widthnumber | null<optional>

The image's number of pixels in a row. It must be provided if the fill style contains an image or different kinds of gradients.

data_heightnumber | null<optional>

The image's number of pixels in a column. It must be provided if the fill style contains an image or different kinds of gradients.

recursiveboolean | null<optional>

Whether to apply the interpolate fill operation to the children of the vector object, default is true.

Returns:

The vector object being built with the interpolate fill operation.

Type: 
VectorObjectBuilder

lerp_stroke(stroke, t, xopt, yopt, widthopt, heightopt, data_widthopt, data_heightopt, recursiveopt) → {VectorObjectBuilder}

Linearly interpolates the stroke Style of the VectorObjectBuilder with another VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
strokeStyle

The vector object to interpolate the stroke style with.

tnumber

The factor to interpolate the stroke style by.

xnumber | null<optional>

The image's top left corner x-coordinate. It must be provided if the stroke style contains an image or different kinds of gradients.

ynumber | null<optional>

The image's top left corner y-coordinate. It must be provided if the stroke style contains an image or different kinds of gradients.

widthnumber | null<optional>

The image's rendering width. It must be provided if the stroke style contains an image or different kinds of gradients.

heightnumber | null<optional>

The image's rendering height. It must be provided if the stroke style contains an image or different kinds of gradients.

data_widthnumber | null<optional>

The image's number of pixels in a row. It must be provided if the stroke style contains an image or different kinds of gradients.

data_heightnumber | null<optional>

The image's number of pixels in a column. It must be provided if the stroke style contains an image or different kinds of gradients.

recursiveboolean | null<optional>

Whether to apply the interpolate stroke operation to the children of the vector object, default is true.

Returns:

The vector object being built with the interpolate stroke operation.

Type: 
VectorObjectBuilder

line_to(p) → {VectorObjectBuilder}

Draws a line from the current drawing point to the given Point2D.

Parameters:
NameTypeDescription
pPoint2D

The point to draw a line to.

Returns:

The vector object being built with the line to operation.

Type: 
VectorObjectBuilder

match_style_properties(vector_object_builder) → {VectorObjectBuilder}

Matches the style properties of the VectorObjectBuilder with another VectorObject.

Parameters:
NameTypeDescription
vector_object_builderVectorObjectBuilder

The vector object to match the style properties of.

Returns:

The vector object being built with the match style properties operation.

Type: 
VectorObjectBuilder

move_point(point) → {VectorObjectBuilder}

Moves the current drawing point to the given Point2D.

Parameters:
NameTypeDescription
pointPoint2D

The point to start a new bezier curve at.

Returns:

The vector object being built with the move point operation.

Type: 
VectorObjectBuilder

move_to(point, recursiveopt) → {VectorObjectBuilder}

Centers the VectorObjectBuilder at the given Point2D.

Parameters:
NameTypeAttributesDescription
pointPoint2D

The point to center the vector object at.

recursiveboolean | null<optional>

Whether to apply the move to operation to the children of the vector object.

Returns:

The vector object being built with the move to operation.

Type: 
VectorObjectBuilder

next_to_other(other, directionopt, buffopt, aligned_edgeopt, recursiveopt) → {VectorObjectBuilder}

Puts the VectorObjectBuilder next to the given VectorObjectBuilder at the given direction, with a buff distance between them and aligning at the given edge.

Parameters:
NameTypeAttributesDescription
otherVectorObjectBuilder

The other vector object to translate the vector object to.

directionPoint2D | null<optional>

The direction to translate the vector object in. If not given, the vector object will be at the right of the other vector object, default is right.

buffnumber | null<optional>

The buffer to leave between the vector object and the other vector object. If not given, the vector object will be touching the other vector object, default is 0.

aligned_edgePoint2D | null<optional>

The edge of the vector object to align with the other vector object. If not given, the vector object will be aligned at the middle, default is the middle.

recursiveboolean | null<optional>

Whether to apply the next to other operation to the children of the vector object. If not given, the operation will be applied to the children, default is true.

Returns:

The vector object being built with the next to other operation.

Type: 
VectorObjectBuilder

next_to_point(point, directionopt, buffopt, aligned_edgeopt, recursiveopt) → {VectorObjectBuilder}

Puts the VectorObjectBuilder next to the given Point2D at the given direction, with a buff distance between them and aligning at the given edge.

Parameters:
NameTypeAttributesDescription
pointPoint2D

The point to translate the vector object to.

directionPoint2D | null<optional>

The direction to translate the vector object in. If not given, the vector object will be at the right of the point, default is right.

buffnumber | null<optional>

The buffer to leave between the vector object and the point. If not given, the vector object will be touching the point, default is 0.

aligned_edgePoint2D | null<optional>

The edge of the vector object to align with the point. If not given, the vector object will be aligned at the middle, default is the middle.

recursiveboolean | null<optional>

Whether to apply the next to point operation to the children of the vector object. If not given, the operation will be applied to the children, default is true.

Returns:

The vector object being built with the next to point operation.

Type: 
VectorObjectBuilder

pointwise_become_partial(start, end, recursiveopt) → {VectorObjectBuilder}

Trims the path of the VectorObjectBuilder to the given start and end proportions.

Parameters:
NameTypeAttributesDescription
startnumber

The proportion of the path to start at.

endnumber

The proportion of the path to end at.

recursiveboolean | null<optional>

Whether to apply the pointwise become partial operation to the children of the vector object, default is true

Returns:
Type: 
VectorObjectBuilder

quadratic_curve_to(p1, p2) → {VectorObjectBuilder}

Draws a quadratic bezier curve from the current drawing point with the given control Point2D and end Point2D.

Parameters:
NameTypeDescription
p1Point2D

The control point of the quadratic curve.

p2Point2D

The end point of the quadratic curve.

Returns:

The vector object being built with the quadratic curve to operation.

Type: 
VectorObjectBuilder

remove_child_by_index(index) → {VectorObjectBuilder}

Removes a child from the VectorObjectBuilder given its index.

Parameters:
NameTypeDescription
indexnumber

The index of the child to remove from the vector object.

Returns:

The vector object being built with the remove child by index operation.

Type: 
VectorObjectBuilder

remove_child_by_name(name) → {VectorObjectBuilder}

Removes a child from the VectorObjectBuilder given its name.

Parameters:
NameTypeDescription
namestring

The name of the child to remove from the vector object.

Returns:

The vector object being built with the remove child by name operation.

Type: 
VectorObjectBuilder

remove_children_at_indices(indices) → {VectorObjectBuilder}

Removes all children with the given indices from the VectorObjectBuilder.

Parameters:
NameTypeDescription
indicesArray.<number>

The indices of the children to remove from the vector object.

Returns:

The vector object being built with the remove children at indices operation.

Type: 
VectorObjectBuilder

remove_children_by_names(names) → {VectorObjectBuilder}

Removes all children with the given names from the VectorObjectBuilder.

Parameters:
NameTypeDescription
namesArray.<string>

The names of the children to remove from the vector object.

Returns:

The vector object being built with the remove children by names operation.

Type: 
VectorObjectBuilder

reverse_path() → {VectorObjectBuilder}

Reverses the path of the VectorObjectBuilder.

Returns:

The vector object being built with the reverse path operation.

Type: 
VectorObjectBuilder

rotate(angle, from_pointopt, recursiveopt) → {VectorObjectBuilder}

Rotates the VectorObjectBuilder by the given angle in radians.

Parameters:
NameTypeAttributesDescription
anglenumber

The angle in radians to rotate the vector object by.

from_pointPoint2D | null<optional>

The point to rotate the vector object about, default is the center of the bounding box.

recursiveboolean | null<optional>

Whether to apply the rotate operation to the children of the vector object, default is true.

Returns:

The vector object being built with the rotate operation.

Type: 
VectorObjectBuilder

scale(factor_x, factor_y, about_pointopt, recursiveopt) → {VectorObjectBuilder}

Scales the VectorObjectBuilder by the given factor.

Parameters:
NameTypeAttributesDescription
factor_xnumber

The factor to scale the vector object by.

factor_ynumber

The factor to scale the vector object by.

about_pointPoint2D | null<optional>

The point to scale the vector object about.

recursiveboolean | null<optional>

Whether to apply the scale operation to the children of the vector object, default is true.

Returns:

The vector object being built with the scale operation.

Type: 
VectorObjectBuilder

scale_to_height(height, stretchopt, about_pointopt, recursiveopt) → {VectorObjectBuilder}

Scales the VectorObjectBuilder to the given height.

Parameters:
NameTypeAttributesDescription
heightnumber

The height to scale the vector object to.

stretchboolean | null<optional>

Whether to stretch the vector object to the given height, default is false.

about_pointPoint2D | null<optional>

The point to scale the vector object about, default is the center of the bounding box.

recursiveboolean | null<optional>

Whether to apply the scale to height operation to the children of the vector object, default is true.

Returns:

The vector object being built with the scale to height operation.

Type: 
VectorObjectBuilder

scale_to_width(width, stretchopt, about_pointopt, recursiveopt) → {VectorObjectBuilder}

Scales the VectorObjectBuilder to the given width.

Parameters:
NameTypeAttributesDescription
widthnumber

The width to scale the vector object to.

stretchboolean | null<optional>

Whether to stretch the vector object to the given width, default is false.

about_pointPoint2D | null<optional>

The point to scale the vector object about, default is the center of the bounding box.

recursiveboolean | null<optional>

Whether to apply the scale to width operation to the children of the vector object, default is true.

Returns:

The vector object being built with the scale to width operation.

Type: 
VectorObjectBuilder

set_actual_path(actual_path) → {VectorObjectBuilder}

Sets the actual path of the VectorObjectBuilder. Actual path is the path that is drawn with its transformation matrix applied.

Parameters:
NameTypeDescription
actual_pathPath2D

The path to set the vector object to.

Returns:

The vector object being built with the set actual path operation.

Type: 
VectorObjectBuilder

set_children(children) → {VectorObjectBuilder}

Sets the children of the VectorObjectBuilder.

Parameters:
NameTypeDescription
childrenArray.<VectorObjectBuilder>

The children to set the vector object to.

Returns:

The vector object being built with the set children operation.

Type: 
VectorObjectBuilder

set_fill(fill, recursiveopt) → {VectorObjectBuilder}

Sets the fill Style of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
fillStyle

The fill style to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set fill operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set fill operation.

Type: 
VectorObjectBuilder

set_fill_rule(fill_rule, recursiveopt) → {VectorObjectBuilder}

Sets the fill rule of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
fill_rulestring

The fill rule to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set fill rule operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set fill rule operation.

Type: 
VectorObjectBuilder

set_name(nameopt) → {VectorObjectBuilder}

Sets the name of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
namestring | null<optional>

The name to set the vector object to.

Returns:

The vector object being built with the set name operation.

Type: 
VectorObjectBuilder

set_path(path) → {VectorObjectBuilder}

Sets the Path2D of the VectorObjectBuilder.

Parameters:
NameTypeDescription
pathPath2D

The path to set the vector object to.

Returns:

The vector object being built with the set path operation.

Type: 
VectorObjectBuilder

set_slice_children(start, end, children) → {VectorObjectBuilder}

Sets the children from the start index to the end index of the VectorObjectBuilder.

Parameters:
NameTypeDescription
startnumber

The start index of the children to replace.

endnumber

The end index of the children to replace.

childrenArray.<VectorObjectBuilder>

The children to replace the children from the start index to the end index with.

Returns:

The vector object being built with the set slice children operation.

Type: 
VectorObjectBuilder

set_stroke(stroke, recursiveopt) → {VectorObjectBuilder}

Sets the stroke Style of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
strokeStyle

The stroke style to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke operation.

Type: 
VectorObjectBuilder

set_stroke_dash_array(stroke_dash_array, recursiveopt) → {VectorObjectBuilder}

Sets the stroke dash array of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
stroke_dash_arrayArray.<number>

The stroke dash array to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke dash array operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke dash array operation.

Type: 
VectorObjectBuilder

set_stroke_dash_offset(stroke_dash_offset, recursiveopt) → {VectorObjectBuilder}

Sets the stroke dash offset of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
stroke_dash_offsetnumber

The stroke dash offset to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke dash offset operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke dash offset operation.

Type: 
VectorObjectBuilder

set_stroke_line_cap(stroke_line_cap, recursiveopt) → {VectorObjectBuilder}

Sets the stroke line cap of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
stroke_line_capstring

The stroke line cap to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke line cap operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke line cap operation.

Type: 
VectorObjectBuilder

set_stroke_line_join(stroke_line_join, recursiveopt) → {VectorObjectBuilder}

Sets the stroke line join of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
stroke_line_joinstring

The stroke line join to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke line join operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke line join operation.

Type: 
VectorObjectBuilder

set_stroke_miter_limit(stroke_miter_limit, recursiveopt) → {VectorObjectBuilder}

Sets the stroke miter limit of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
stroke_miter_limitnumber

The stroke miter limit to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke miter limit operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke miter limit operation.

Type: 
VectorObjectBuilder

set_stroke_width(stroke_width, recursiveopt) → {VectorObjectBuilder}

Sets the stroke width of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
stroke_widthnumber

The stroke width to set the vector object to.

recursiveboolean | null<optional>

Whether to apply the set stroke width operation to the children of the vector object, default is true.

Returns:

The vector object being built with the set stroke width operation.

Type: 
VectorObjectBuilder

set_transform(matrix, recursiveopt) → {VectorObjectBuilder}

Sets the TransformationMatrix of the VectorObjectBuilder.

Parameters:
NameTypeAttributesDescription
matrixTransformationMatrix

The matrix in CSS format to transform the vector object by.

recursiveboolean | null<optional>

Whether to apply the transform operation to the children of the vector object.

Returns:

The vector object being built with the transform operation.

Type: 
VectorObjectBuilder

shift(dx, dy, recursiveopt) → {VectorObjectBuilder}

Shifts the VectorObjectBuilder by the given dx and dy.

Parameters:
NameTypeAttributesDescription
dxnumber

The x-coordinate to translate the vector object by.

dynumber

The y-coordinate to translate the vector object by.

recursiveboolean | null<optional>

Whether to apply the shift operation to the children of the vector object, default is true.

Returns:

The vector object being built with the shift operation.

Type: 
VectorObjectBuilder

(static) default_tip_shape(tip_length) → {VectorObjectBuilder}

Returns the default tip shape pointing to the right and centered at the origin as a VectorObjectBuilder.

Parameters:
NameTypeDescription
tip_lengthnumber

The length of the tip shape.

Returns:

The default tip shape pointing to the right and centered at the origin.

Type: 
VectorObjectBuilder

(static) default_vector_object_builder() → {VectorObjectBuilder}

Creates a VectorObjectBuilder representing an empty VectorObject.

Returns:

A new vector object builder representing an empty vector object.

Type: 
VectorObjectBuilder

(static) from_svg(svg, font_facesopt, image_libraryopt) → {VectorObjectBuilder}

Creates a new VectorObjectBuilder from an SVG string.

Parameters:
NameTypeAttributesDescription
svgstring

The SVG string to create the vector object builder from.

font_facesArray.<FontFace> | null<optional>

Data from font faces to use for text rendering.

image_libraryImageLibrary | null<optional>

Image library to use for image rendering.

Returns:

A new vector object builder.

Type: 
VectorObjectBuilder