# Two.Points

Extends: Two.Shape

This is a primary primitive class for quickly and easily drawing points in Two.js. Unless specified methods return their instance of Two.Points for the purpose of chaining.

# Constructor

Argument Description
vertices A list of Two.Vectors that represent the order and coordinates to construct a rendered set of points.

# sizeAttenuation

Boolean dictating whether Two.js should scale the size of the points based on its matrix hierarchy.

Set to true if you'd like the size of the points to be relative to the scale of its parents; false to disregard. Default is false.

# beginning

Number between zero and one to state the beginning of where the path is rendered.

Two.Points.beginning is a percentage value that represents at what percentage into the path should the renderer start drawing.

# ending

Number between zero and one to state the ending of where the path is rendered.

Two.Points.ending is a percentage value that represents at what percentage into the path should the renderer start drawing.

# fill

The value of what the path should be filled in with.

See: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (opens new window) for more information on CSS's colors as String.

# stroke

The value of what the path should be outlined in with.

See: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (opens new window) for more information on CSS's colors as String.

# className

A class to be applied to the element to be compatible with CSS styling.

nota-bene

Only available for the SVG renderer.

# visible

Display the points or not.

nota-bene

For Two.CanvasRenderer and Two.WebGLRenderer when set to false all updating is disabled improving performance dramatically with many objects in the scene.

# vertices

An ordered list of vector points for rendering points.

A list of Two.Vector objects that consist of which coordinates to draw points at.

nota-bene

The array when manipulating is actually a Two.Collection.

# dashes

Array of numbers. Odd indices represent dash length. Even indices represent dash space.

A list of numbers that represent the repeated dash length and dash space applied to the stroke of the text.

See: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray (opens new window) for more information on the SVG stroke-dasharray attribute.

# dashes.offset

A number in pixels to offset Two.Points.dashes display.

# clone

Returns: Two.Points

Argument Description
parent The parent group or scene to add the clone to.

Create a new instance of Two.Points with the same properties of the current path.

# toObject

Returns: Object

Return a JSON compatible plain object that represents the points object.

# noFill

Short hand method to set fill to none.

# noStroke

Short hand method to set stroke to none.

# corner

Orient the vertices of the shape to the upper left-hand corner of the points object.

# center

Orient the vertices of the shape to the center of the points object.

# getBoundingClientRect

Returns: Object

  • Returns object with top, left, right, bottom, width, height attributes.
Argument Description
shallow Describes whether to calculate off local matrix or world matrix.

Return an object with top, left, right, bottom, width, and height parameters of the path.

# subdivide

Argument Description
limit How many times to recurse subdivisions.

Insert a Two.Vector at the midpoint between every item in Two.Points.vertices.

# length

The sum of distances between all Two.Points.vertices.