Shape object

app.project.item(index).layer(index).property(index).property(maskShape").value

Description

The Shape object encapsulates information describing a shape in a shape layer, or the outline shape of a Mask.
It is the value of the “Mask Path” AE properties, and of the “Path” AE property of a shape layer. Use the constructor, new Shape() , to create a new, empty Shape object, then set the attributes individually to define the shape.

A shape has a set of anchor points, or vertices, and a pair of direction handles, or tangent vectors, for each anchor point. A tangent vector (in a non-RotoBezier mask) determines the direction of the line that is drawn to or from an anchor point. There is one incoming tangent vector and one outgoing tangent vector associated with each vertex in the shape.

A tangent value is a pair of x,y coordinates specified relative to the associated vertex. For example, a tangent of [-1,-1] is located above and to the left of the vertex and has a 45 degree slope, regardless of the actual location of the vertex. The longer a handle is, the greater its influence; for example, an incoming shape segment stays closer to the vector for an inTangent of [-2,-2] than it does for an inTangent of [-1,-1], even though both of these come toward the vertex from the same direction.

If a shape is not closed, the inTangent for the first vertex and the outTangent for the final vertex are ignored.
If the shape is closed, these two vectors specify the direction handles of the final connecting segment out of the final vertex and back into the first vertex.

RotoBezier masks calculate their tangents automatically. (See “MaskPropertyGroup rotoBezier attribute” .) If a shape is used in a RotoBezier mask, the tangent values are ignored. This means that, for RotoBezier masks, you can construct a shape bysetting only the vertices attribute and setting both inTangents
and outTangents to null. When you access the new shape, its tangent valuesare filled with the automatically calculated tangent values.

For closed mask shapes, variable-width mask feather points can exist anywhere along the mask path. Feather points are part of the Mask Path property. Reference a specific feather point by the number of the mask path segment (portion of the path between adjacent vertices) where it appears.

NOTE: The feather points on a mask are listed in an array in the order that they were created.

Example: Create a square mask

A square is a closed shape with 4 vertices. The inTangents and outTangents for connected straight-line segments are 0, the default, and do not need to be explicitly set.
var myShape = new Shape();
myShape.vertices = [[0,0], [0,100], [100,100], [100,0]];
myShape.closed = true;

Example: Create a “U” shaped mask

A “U” is an open shape with the same 4 vertices used in the square:
var myShape = new Shape();
myShape.vertices = [[0,0], [0,100], [100,100], [100,0]];
myShape.closed = false;

Example: Create an oval

An oval is a closed shape with 4 vertices and withinTangent and outTangent values:
var myShape = new Shape();
myShape.vertices = [[300,50],[200,150],[300,250],[400,150]];
myShape.inTangents = [[55.23,0],[0,-55.23],[-55.23,0],[0,55.23]];
myShape.outTangents = [[-55.23,0],[0,55.23],[55.23,0],[0,-55.23]];
myShape.closed = true;

Example: Create a square mask with two feather points

A large square mask with two feather points, one closer to the left end the second mask segment (off the bottom edge) with a radius of 30 pixels and the other one centered the third mask segment (off the right edge) with a larger radius of 100 pixels.
var myShape = new Shape();
myShape.vertices = [[100,100], [100,400], [400,400], [400,100]]; // segments drawn counterclockwise
myShape.closed = true;

myShape.featherSegLocs = [1,2]; // segments are numbered starting at 0, so second segment is 1
myShape.featherRelSegLocs = [0.15, 0.5]; // 0.15 is closer to the lower-left corner of the square
myShape.featherRadii = [30, 100]; // second feather point (on right-side segment) has a larger radius

Attributes

Attribute Reference Description
closed “Shape closed attribute” When true, the shape is a closed curve.
vertices “Shape vertices attribute” The anchor points of the shape.
inTangents “Shape inTangents attribute” The tangent vectors coming into the shape vertices.
outTangents “Shape outTangents attribute” The tangent vectors coming out of the shape vertices.
featherSegLocs “Shape featherSegLocs attribute” The mask path segment (sections of a mask path
between vertices) containing each feather point.
featherRelSegLocs “Shape featherRelSegLocs attribute” The relative position of each feather point on its mask
path segment.
featherRadii “Shape featherRadii attribute” The feather amount (radius) for each feather point.
featherInterps “Shape featherInterps attribute” The feather radius interpolation type for each feather
point.
featherTensions “Shape featherTensions attribute” The feather tension at each feather point.
featherTypes “Shape featherTypes attribute” The direction (inner or outer) of each feather point.
featherRelCornerAngles “Shape featherRelCornerAngles attribute” The relative angle between the two normals on either side of a curved outer feather boundary at a corner on a mask path.

Other Tags

Posted in Shape object and tagged , , , , , , , , , , , , , , .