Shapes
The graphical elements are divided in 4 categories:
- Shapes that define the actual curves but have no styling information
- Grouping, used to organize collections of graphic elements
- Styles, that define the visual appearance of shapes
- Modifiers alter the curves of the shapes
Shape Rendering Model
Grouping and Ordering Rules
- Shapes are rendered in reverse order, bottom->top. Shapes at the beginning of the array are rendered on top of shapes with larger indices.
- Groups offer a scoping mechanism for transforms, styles, modifiers, and shapes. All group children, including sub-groups and their children, are considered part of the group's scope.
- Transforms adjust the coordinate system for all elements within their group, and transitively for all other group-nested elements.
- Styles and modifiers apply to all preceding shapes within the current scope, including subgroup-nested shapes.
- When multiple styles apply to the same shape, the shape is rendered repeatedly for each style, in reverse order.
- When multiple modifiers apply to the same shape, they are composed in reverse order (e.g. ).
- When multiple transforms apply to the same shape due to scope nesting, they compose in group nesting order (transforms are additive).
- Group opacity (property of the group transform) applies atomically to all elements in scope - i.e. opacity applies to the result of compositing all group content, and not to individual elements.
More formally:
- for each tuple, where and :
- for each , in increasing index order, where and
:
- compute the total shape transformation by composing all transforms within the shape scope chain:
-
compute the total style transformation by composing all transforms within the style scope chain:
-
Notes
-
Certain modifier operations (e.g. sequential ) may require information about shapes from different groups, thus calls cannot always be issued based on single-pass local knowledge.
-
Transforms can affect both shapes and styles (e.g. stroke width). For a given , the shape and style transforms are not necessarily equal.
-
Shapes without an applicable style are not rendered.
-
This rendering model is based on AfterEffects' Shape Layer semantics.
Rendering Convention
Shapes defined in this section contain rendering instructions. These instructions are used to generate the path as a bezier curve.
Implementations MAY use different algorithms or primitives to render the shapes but the result MUST be equivalent to the paths defined here.
Some instructions define named values for clarity and illustrative purposes, implementations are not required to have them explicitly defined in their rendering process.
When referencing animated properties, the rendering instruction will
use the same name as in the JSON but it's assumed they refer to their
value at a given point in time rather than the property itself.
For Vector values, and in
the instructions are equivalent to value[0]
and value[1]
respectively.
All paths MUST be closed unless specified otherwise in the rendering instructions.
When instructions call for an equality comparison between two values, implementations MAY consider similar values to be equal to overcome numerical instability.
Drawing Commands
Drawing instructions will contain the following commands:
- add vertex: Adds a vertex to the bezier shape in global coordinates
- set in tangent: Sets the cubic tangent to the last added vertex, with coordinates relative to it. If omitted, tangents MUST be .
- set out tangent: Sets the cubic tangent from the last added vertex, with coordinates relative to it. If omitted, tangents MUST be .
- lerp: Linearly interpolates two points or scalars by a given amount.
Approximating Ellipses with Cubic Bezier
An elliptical quadrant can be approximated by a cubic bezier segment with tangents of length $radius \cdot E_t.
Where
See this article for the math behind it.
When implementations render elliptical arcs using bezier curves, they SHOULD use this constant, a similar approximation, or elliptical arc drawing primitives.
Graphic Element
Element used to display vector data in a shape layer
Composition Diagram for Graphic Element
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string |
Shape Type |
Shape Type |
The ty
property defines the specific element type based on the following values:
ty |
Type |
---|---|
'el' |
Ellipse |
'fl' |
Fill |
'gf' |
Gradient |
'gs' |
Gradient Stroke |
'gr' |
Group |
'sh' |
Path |
'sr' |
PolyStar |
'rc' |
Rectangle |
'st' |
Stroke |
'tr' |
Transform Shape |
'tm' |
Trim Path |
None |
Unknown shape types |
Hidden shapes (hd: True
) are ignored, and do not contribute to rendering nor modifier operations.
Shapes
Drawable shape, defines the actual shape but not the style
Composition Diagram for Shape
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string |
Shape Type |
Shape Type |
d |
Shape Direction |
Direction |
Direction the shape is drawn as, mostly relevant when using trim path |
Ellipse
Ellipse shape
Composition Diagram for Ellipse
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'el' |
Shape Type |
Shape Type |
d |
Shape Direction |
Direction |
Direction the shape is drawn as, mostly relevant when using trim path |
p |
Position |
Position |
Position |
s |
Vector |
Size |
Size |
Example
256 | |
256 | |
256 | |
256 |
An ellipse is drawn from the top quandrant point going clockwise:
- Add vertex
- Set in tangent
- Set out tangent
- Add vertex
- Set in tangent
- Set out tangent
- Add vertex
- Set in tangent
- Set out tangent
- Add vertex
- Set in tangent
- Set out tangent
Implementations MAY use elliptical arcs to render an ellipse.
Rectangle
A simple rectangle shape
Composition Diagram for Rectangle
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'rc' |
Shape Type |
Shape Type |
d |
Shape Direction |
Direction |
Direction the shape is drawn as, mostly relevant when using trim path |
p |
Position |
Position |
Center of the rectangle |
s |
Vector |
Size |
Size |
r |
Scalar |
Rounded |
Rounded corners radius |
Example
256 | |
256 | |
256 | |
256 | |
0 |
Definitions:
If , then the rectangle is rendered from the top-right going clockwise:
- Add vertex
- Add vertex
- Add vertex
- Add vertex
If , the rounded corners must be taken into account.
- Add vertex
- Set in tangent
- Add vertex
- Set out tangent
- Add vertex
- Set in tangent
- Add vertex
- Set out tangent
- Add vertex
- Set in tangent
- Add vertex
- Set out tangent
- Add vertex
- Set in tangent
- Add vertex
- Set out tangent
Path
Custom Bezier shape
Composition Diagram for Path
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'sh' |
Shape Type |
Shape Type |
d |
Shape Direction |
Direction |
Direction the shape is drawn as, mostly relevant when using trim path |
ks |
Bezier |
Shape |
Bezier path |
Example
PolyStar
Star or regular polygon
Composition Diagram for PolyStar
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'sr' |
Shape Type |
Shape Type |
d |
Shape Direction |
Direction |
Direction the shape is drawn as, mostly relevant when using trim path |
p |
Position |
Position |
Position |
or |
Scalar |
Outer Radius |
Outer Radius |
os |
Scalar |
Outer Roundness |
Outer Roundness as a percentage |
r |
Scalar |
Rotation |
Rotation, clockwise in degrees |
pt |
Scalar |
Points |
Points |
sy |
Star Type |
Star Type |
Star Type |
ir |
Scalar |
Inner Radius |
Inner Radius |
is |
Scalar |
Inner Roundness |
Inner Roundness as a percentage |
Example
256 | |
256 | |
5 | |
0 | |
200 | |
100 | |
0 | |
0 | |
Definitions:
- For in
- Let
- Let
- Add vertex
- If , we need to add bezier tangent
- Let
- Set in tangent
- Set out tangent
- If , we need to add a vertex towards the inner radius to make a star
- Let
- Add vertex
- If , we need to add bezier tangent
- Let
- Set in tangent
- Set out tangent
Grouping
Group
Shape Element that can contain other shapes
Composition Diagram for Group
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'gr' |
Shape Type |
Shape Type |
np |
number |
Number Of Properties |
Number Of Properties |
it |
array of Graphic Element |
Shapes |
Shapes |
A group defines a render stack, elements within a group MUST be rendered in reverse order (the first object in the list will appear on top of elements further down).
- Apply the transform
- Render Styles and child groups in the transformed coordinate system.
Transform
Group transform
Composition Diagram for Transform Shape
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'tr' |
Shape Type |
Shape Type |
a |
Position |
Anchor Point |
Anchor point: a position (relative to its parent) around which transformations are applied (ie: center for rotation / scale) |
p |
Splittable Position |
Position |
Position / Translation |
r |
Scalar |
Rotation |
Rotation in degrees, clockwise |
s |
Vector |
Scale |
Scale factor, |
o |
Scalar |
Opacity |
Opacity |
sk |
Scalar |
Skew |
Skew amount as an angle in degrees |
sa |
Scalar |
Skew Axis |
Direction along which skew is applied, in degrees ( |
Transform shapes MUST always be present in the group and they MUST be
the last item in the it
array.
They modify the group's coordinate system the same way as Layer Transform.
Style
Describes the visual appearance (like fill and stroke) of neighbouring shapes
Composition Diagram for Shape Style
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string |
Shape Type |
Shape Type |
o |
Scalar |
Opacity |
Opacity, 100 means fully opaque |
Shapes styles MUST apply their style to the collected shapes that come before them in stacking order.
Fill
Solid fill color
Composition Diagram for Fill
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'fl' |
Shape Type |
Shape Type |
o |
Scalar |
Opacity |
Opacity, 100 means fully opaque |
c |
Color |
Color |
Color |
r |
Fill Rule |
Fill Rule |
Fill Rule |
Example
1 | |
0.98 | |
0.28 | |
100 | |
Stroke
Solid stroke
Composition Diagram for Stroke
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'st' |
Shape Type |
Shape Type |
o |
Scalar |
Opacity |
Opacity, 100 means fully opaque |
lc |
Line Cap |
Line Cap |
Line Cap |
lj |
Line Join |
Line Join |
Line Join |
ml |
number |
Miter Limit |
Miter Limit |
ml2 |
Scalar |
Miter Limit |
Animatable alternative to ml |
w |
Scalar |
Width |
Stroke width |
d |
array of Stroke Dash |
Dashes |
Dashed line definition |
c |
Color |
Color |
Stroke color |
Example
1 | |
0.98 | |
0.28 | |
32 | |
100 | |
3 |
Stroke Dashes
An item used to described the dash pattern in a stroked path
Composition Diagram for Stroke Dash
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
n |
Stroke Dash Type |
Dash Type |
Dash Type |
v |
Scalar |
Length |
Length of the dash |
Example
1 | |
0.98 | |
0.28 | |
32 | |
100 | |
3 | |
0 | |
30 | |
50 |
Gradient Fill
Gradient fill color
Composition Diagram for Gradient
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'gf' |
Shape Type |
Shape Type |
o |
Scalar |
Opacity |
Opacity, 100 means fully opaque |
g |
Gradient |
Colors |
Gradient colors |
s |
Position |
Start Point |
Starting point for the gradient |
e |
Position |
End Point |
End point for the gradient |
t |
Gradient Type |
Gradient Type |
Type of the gradient |
h |
Scalar |
Highlight Length |
Highlight Length, as a percentage between |
a |
Scalar |
Highlight Angle |
Highlight Angle in clockwise degrees, relative to the direction from |
r |
Fill Rule |
Fill Rule |
Fill Rule |
Example
256 | |
496 | |
256 | |
16 | |
0 | |
0 |
Gradient Stroke
Gradient stroke
Composition Diagram for Gradient Stroke
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'gs' |
Shape Type |
Shape Type |
o |
Scalar |
Opacity |
Opacity, 100 means fully opaque |
lc |
Line Cap |
Line Cap |
Line Cap |
lj |
Line Join |
Line Join |
Line Join |
ml |
number |
Miter Limit |
Miter Limit |
ml2 |
Scalar |
Miter Limit |
Animatable alternative to ml |
w |
Scalar |
Width |
Stroke width |
d |
array of Stroke Dash |
Dashes |
Dashed line definition |
g |
Gradient |
Colors |
Gradient colors |
s |
Position |
Start Point |
Starting point for the gradient |
e |
Position |
End Point |
End point for the gradient |
t |
Gradient Type |
Gradient Type |
Type of the gradient |
h |
Scalar |
Highlight Length |
Highlight Length, as a percentage between |
a |
Scalar |
Highlight Angle |
Highlight Angle in clockwise degrees, relative to the direction from |
Example
256 | |
496 | |
256 | |
16 | |
0 | |
0 |
Modifiers
Modifiers change the bezier curves of neighbouring shapes
Modifiers replace shapes in the render stack by applying operating on the bezier path of to the collected shapes that come before it in stacking order.
Trim Path
Trims shapes into a segment
Composition Diagram for Trim Path
Attribute | Type | Title | Description |
---|---|---|---|
nm |
string |
Name |
Human readable name, as seen from editors and the like |
hd |
boolean |
Hidden |
Whether the shape is hidden |
ty |
string = 'tm' |
Shape Type |
Shape Type |
s |
Scalar |
Start |
Segment start |
e |
Scalar |
End |
Segment end |
o |
Scalar |
Offset |
Offset |
m |
Trim Multiple Shapes |
Multiple |
How to treat multiple copies |
0 | |
50 | |
0 | |
When rendering trim path, the order of bezier points MUST be the same as rendering instructions given for each shape in this section.
Rendering trim path can be rather complex.
Given
If and are equal, implementations MUST NOT render any shapes.
If and , the input shape MUST be rendered as-is.
To render trim path, implementations MUST consider the actual length of each shape (they MAY use approximations). Once the shapes are collected, the segment to render is given by the percentages and .
When trim path is applied to multiple shapes, the m
property MUST
be considered when applying the modifier:
-
When
m
has a value of1
(Parallel), each shape MUST considered separately, and being applied to each shape. -
When
m
has a value of2
(Sequential), all the shapes MUST be considered as following each other in render order. and refer to the whole length created by concatenating each shape.