Shapes

The graphical elements are divided in 4 categories:

Shape Rendering Model

Grouping and Ordering Rules

More formally:

Notes

  1. Certain modifier operations (e.g. sequential Trim) may require information about shapes from different groups, thus Render() calls cannot always be issued based on single-pass local knowledge.

  2. Transforms can affect both shapes and styles (e.g. stroke width). For a given (shape,style), the shape and style transforms are not necessarily equal.

  3. Shapes without an applicable style are not rendered.

  4. 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, value.x and value.y 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, implementaions MAY consider similar values to be equal to overcome numerical instability.

Drawing Commands

Drawing instructions will contain the following commands:

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

Et0.5519150244935105707435627

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 daya in a shape layer

Composition Diagram for Graphic Element Graphic Element Visual Object Shape Ellipse Rectangle Path PolyStar Modifier Trim Path Shape Style Fill Stroke Transform Shape Group
Attribute Type Title Description
nm string

Name

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
'gr' Group
'sh' Path
'sr' PolyStar
'rc' Rectangle
'st' Stroke
'tr' Transform Shape
'tm' Trim Path

Shapes

Drawable shape, defines the actual shape but not the style

Composition Diagram for Shape Shape Graphic Element Visual Object Ellipse Rectangle Path PolyStar
Attribute Type Title Description
nm string

Name

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 Ellipse Shape Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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:

radius=s2tangent=radius·Etx=p.xy=p.y
  1. Add vertex (x,yradius.y)
  2. Set in tangent (tangent.x,0)
  3. Set out tangent (tangent.x,0)
  4. Add vertex (x+radius.x,y)
  5. Set in tangent (0,tangent.y)
  6. Set out tangent (0,tangent.y)
  7. Add vertex (x,y+radius.y)
  8. Set in tangent (tangent.x,0)
  9. Set out tangent (tangent.x,0)
  10. Add vertex (xradius.x,y)
  11. Set in tangent (0,tangent.y)
  12. Set out tangent (0,tangent.y)

Implementations MAY use elliptical arcs to render an ellipse.

Ellipse rendering guide

Rectangle

A simple rectangle shape

Composition Diagram for Rectangle Rectangle Shape Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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:

left=p.xs.x2right=p.x+s.x2top=p.ys.y2bottom=p.y+s.y2

If r=0, then the rectangle is rendered from the top-right going clockwise:

  1. Add vertex (right,top)
  2. Add vertex (right,bottom)
  3. Add vertex (left,bottom)
  4. Add vertex (left,top)

If r>0, the rounded corners must be taken into account.

rounded=min(s.x2,s.y2,r)tangent=rounded·Et
  1. Add vertex (right,top+rounded)
  2. Set in tangent (0,tangent)
  3. Add vertex (right,bottomrounded)
  4. Set out tangent (0,tangent)
  5. Add vertex (rightrounded,bottom)
  6. Set in tangent (tangent,0)
  7. Add vertex (left+rounded,bottom)
  8. Set out tangent (tangent,0)
  9. Add vertex (left,bottomrounded)
  10. Set in tangent (0,tangent)
  11. Add vertex (left,top+rounded)
  12. Set out tangent (0,tangent)
  13. Add vertex (left+rounded,top)
  14. Set in tangent (tangent,0)
  15. Add vertex (rightrounded,top)
  16. Set out tangent (tangent,0)

Rectangle rendering guide

Path

Custom Bezier shape

Composition Diagram for Path Path Shape Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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 PolyStar Shape Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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:

points=ptθ=πpointsα=π180·rtanout=os100·or·2πpoints·4tanin=is100·ir·2πpoints·4
  1. For i in [0,points)
    1. Let β=π2+α+i·2θ˙
    2. Let Vout=(or·cos(β),or·sin(β))
    3. Add vertex p+Vout
    4. If or0, we need to add bezier tangent
      1. Let Tout=(Vout·tanoutor)
      2. Set in tangent Vout
      3. Set out tangent Vout
    5. If sy=1, we need to add a vertex towards the inner radius to make a star
      1. Let Vin=(ir·cos(β+θ),or·sin(β+θ))
      2. Add vertex p+Vin
      3. If ir0, we need to add bezier tangent
        1. Let Tin=(Vin·taninor)
        2. Set in tangent Vin
        3. Set out tangent Vin

Grouping

Group

Shape Element that can contain other shapes

Composition Diagram for Group Group Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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

Transform

Group transform

Composition Diagram for Transform Shape Transform Shape Graphic Element Transform Visual Object
Attribute Type Title Description
nm string

Name

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 Position

Position

Position / Translation

r Scalar

Rotation

Rotation in degrees, clockwise

s Vector

Scale

Scale factor, [100, 100] for no scaling

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 (0 skews along the X axis, 90 along the Y axis)

Style

Describes the visual appearance (like fill and stroke) of neighbouring shapes

Composition Diagram for Shape Style Shape Style Graphic Element Visual Object Fill Stroke
Attribute Type Title Description
nm string

Name

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

Fill

Solid fill color

Composition Diagram for Fill Fill Shape Style Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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 Stroke Shape Style Base Stroke Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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 Stroke Dash Visual Object
Attribute Type Title Description
nm string

Name

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

Modifiers

Modifiers change the bezier curves of neighbouring shapes

Trim Path

Trims shapes into a segment

Composition Diagram for Trim Path Trim Path Modifier Graphic Element Visual Object
Attribute Type Title Description
nm string

Name

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

offset={o360o360o0o360o360o<0start=offset+min(1,max(0,min(s,e)100))end=offset+min(1,max(0,max(s,e)100))

If s and e are equal, implementations MUST NOT render any shapes.

If s=0 and e=1, 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 start and end.

When trim path is applied to multiple shapes, the m property MUST be considered when applying the modifier: