Using the rotoscoping functionalities

All rotoscoping functionalities are gathered in the Roto class. For now, only the roto node can have a Roto object. The Roto object is auto-declared by Natron and can be accessed as an attribute of the roto node:


All the objects hierarchy in the Roto object is broken up in 2 classes:

  • BezierCurve: This class represents a single bezier, may it be an ellipse, rectangle or bezier.

  • Layer : This is a container for BezierCurves and Layers

Beziers and layers can be accessed via their script-name directly:


The script-name of the roto items can be found in the settings panel of the Roto node.

Moving items within layers

In Natron, all the items in a layer are rendered from top to bottom, meaning the bottom-most items will always appear on top of the others.

You can re-organize the tree using the functions available in the Layer class.


Removing an item from a layer or inserting it in a layer will change the auto-declared variable, e.g.:

fromLayer = app.Roto1.roto.Layer1 toLayer = app.Roto1.roto.Layer2 item = app.Roto1.roto.Layer1.Bezier1 toLayer.addItem(item)

#Now item is referenced from app.Roto1.roto.Layer2.Bezier1

Creating layers

To create a new BezierCurve, use the createLayer() function made available by the Roto class.

Creating shapes

To create a new BezierCurve, use one of the following functions made available by the Roto class:

  • createBezier(x,y,time)

  • createEllipse(x,y,diameter,fromCenter,time)

  • createRectangle(x,y,size,time)

Once created, the Bezier will have at least 1 control point (4 for ellipses and rectangles) and one keyframe at the time specified in parameter.

A Bezier initially is in an opened state, meaning it doesn’t produce a shape yet (unless it is a rectangle or ellipse). At this stage you can then add control points using the :func`addControlPoint(x,y)<NatronEngine.BezierCurve.addControlPoint>` function. Once you’re one adding control points, call the function setCurveFinished(finished) to close the shape by connecting the last control point with the first.

Once finished, you can refine the Bezier curve by adding control points with the addControlPointOnSegment(index,t) function. You can then move and remove control points of the Bezier.

You can also slave a control point to a track using the slavePointToTrack(index,trackTime,trackCenter) function.

A Bezier curve has several properties that the API allows you to modify:

  • opacity

  • color

  • feather distance

  • feather fall-off

  • enable state

  • overlay color

  • compositing operator

Most of them are available via a parameter, e.g.:

colorParam = bezier.getColorParam() bezierColor = colorParam.get(time)