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, implementations 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 data in a shape layer

Composition Diagram for Graphic Element Graphic Element Visual Object Group Shape Style Fill Gradient Stroke Gradient Stroke Shape PolyStar Path Rectangle Ellipse Transform Shape Modifier 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

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 Shape Graphic Element Visual Object PolyStar Path Rectangle 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

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

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

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

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

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

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

PolyStar

Star or regular polygon

Composition Diagram for PolyStar PolyStar Shape Graphic Element Visual Object
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

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

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).

  1. Apply the transform
  2. Render Styles and child groups in the transformed coordinate system.

Transform

Group transform

Composition Diagram for Transform Shape Transform Shape Graphic Element Transform Visual Object
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, [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)

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 Shape Style Graphic Element Visual Object Fill Gradient Stroke 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

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 Fill Shape Style Graphic Element Visual Object
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

Stroke

Solid stroke

Composition Diagram for Stroke Stroke Shape Style Base Stroke Graphic Element Visual Object
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

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

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

Gradient Fill

Gradient fill color

Composition Diagram for Gradient Gradient Shape Style Base Gradient Graphic Element Visual Object
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 s and e

a Scalar

Highlight Angle

Highlight Angle in clockwise degrees, relative to the direction from s to e

r Fill Rule

Fill Rule

Fill Rule

Gradient Stroke

Gradient stroke

Composition Diagram for Gradient Stroke Gradient Stroke Shape Style Base Stroke Base Gradient Graphic Element Visual Object
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 s and e

a Scalar

Highlight Angle

Highlight Angle in clockwise degrees, relative to the direction from s to e

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 Trim Path Modifier Graphic Element Visual Object
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

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: