# Two.Shape

Extends: Two.Events

The foundational transformation object for the Two.js scenegraph.

# FlagMatrix

Utility function used in conjunction with event handlers to update the flagMatrix of a shape.

# MakeObservable

Argument Description
object The object to make observable.

Convenience function to apply observable qualities of a Two.Shape to any object. Handy if you'd like to extend the Two.Shape class on a custom class.

# renderer

Object access to store relevant renderer specific variables. Warning: manipulating this object can create unintended consequences.

nota-bene

With the Two.SvgRenderer you can access the underlying SVG element created via shape.renderer.elem.

# id

Session specific unique identifier.

nota-bene

In the Two.SvgRenderer change this to change the underlying SVG element's id too.

# classList

A list of class strings stored if imported / interpreted from an SVG element.

# matrix

The transformation matrix of the shape.

nota-bene

Two.Shape.translation, Two.Shape.rotation, Two.Shape.scale, Two.Shape.skewX, and Two.Shape.skewY apply their values to the matrix when changed. The matrix is what is sent to the renderer to be drawn.

# translation

The x and y value for where the shape is placed relative to its parent.

# rotation

The value in Number for how much the shape is rotated relative to its parent.

# scale

The value for how much the shape is scaled relative to its parent.

nota-bene

This value can be replaced with a Two.Vector to do non-uniform scaling. e.g: shape.scale = new Two.Vector(2, 1);

# skewX

The value in Number for how much the shape is skewed relative to its parent.

Skew the shape by an angle in the x axis direction.

# skewY

The value in Number for how much the shape is skewed relative to its parent.

Skew the shape by an angle in the y axis direction.

# className

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

nota-bene

Only available for the SVG renderer.

# addTo

Argument Description
group The parent the shape adds itself to.

Convenience method to add itself to the scenegraph.

# clone

Returns: Two.Shape

Argument Description
parent Optional argument to automatically add the shape to a scenegraph.

Create a new Two.Shape with the same values as the current shape.