BezierCurve
Inherits ItemBase
Synopsis
A BezierCurve is the class used for beziers, ellipses and rectangles. See detailed description….
Functions
def
addControlPoint
(x, y)def
addControlPointOnSegment
(index, t)def
getActivatedParam
()def
getColor
(time)def
getColorParam
()def
getCompositingOperator
()def
getCompositingOperatorParam
()def
getControlPointPosition
(index,time)def
getFeatherDistance
(time)def
getFeatherDistanceParam
()def
getFeatherFallOff
(time)def
getFeatherFallOffParam
()def
getFeatherPointPosition
(index,time)def
getIsActivated
(time)def
getKeyframes
()def
getNumControlPoints
()def
getOpacity
(time)def
getOpacityParam
()def
getOverlayColor
()def
isCurveFinished
()def
moveFeatherByIndex
(index, time, dx, dy)def
moveLeftBezierPoint
(index, time, dx, dy)def
movePointByIndex
(index, time, dx, dy)def
moveRightBezierPoint
(index, time, dx, dy)def
removeControlPointByIndex
(index)def
setActivated
(time, activated)def
setColor
(time, r, g, b)def
setCompositingOperator
(op)def
setCurveFinished
(finished)def
setFeatherDistance
(dist, time)def
setFeatherFallOff
(falloff, time)def
setFeatherPointAtIndex
(index, time, x, y, lx, ly, rx, ry)def
setOpacity
(opacity, time)def
setOverlayColor
(r, g, b)def
setPointAtIndex
(index, time, x, y, lx, ly, rx, ry)
Detailed Description
Almost all functionalities available to the user have been made available to the Python API, although in practise making a shape just by calling functions might be tedious due to the potential huge number of control points and keyframes. You can use the Natron Group node’s export functionality to generate automatically a script from a Roto node within that group.
A Bezier initially is in an opened state, meaning it doesn’t produce a shape yet.
At this stage you can then add control points using the addControlPoint(x,y)
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.
To get the position of the control points of the Bezier as well as the position of the feather
points, use the functions getControlPointPosition
and
getFeatherPointPosition
.
The index passed to the function must be between 0 and getNumControlPoints
-1.
The time passed to the function corresponds to a time on the timeline’s in frames. If it lands on a keyframe of the Bezier shape, then the position at that keyframe is returned, otherwise the position is sampled between the surrounding keyframes.
To get a list of all keyframes time for a Bezier call the function getKeyframes()
.
A Bezier curve has several parameters that the API allows you to modify:
opacity
color
feather distance
feather fall-off
enable state
overlay color
compositing operator
Each of them is a regular Param
that you can access to modify
or query its properties.
All parameters can be retrieved with their script-name with the function getParam(scriptName)
.
Member functions description
- NatronEngine.BezierCurve.CairoOperatorEnum
This enumeration represents the different blending modes of a shape. See the user interface for the different modes, or type help(NatronEngine.BezierCurve.CairoOperatorEnum) to see the different values.
- NatronEngine.BezierCurve.addControlPoint(x, y)
- Parameters
x –
float
y –
float
Adds a new control point to an opened shape (see isCurveFinished()
) at coordinates (x,y).
By default the feather point attached to this point will be equivalent to the control point.
If the auto-keying is enabled in the user interface, then this function will set a keyframe at
the timeline’s current time for this shape.
- NatronEngine.BezierCurve.addControlPointOnSegment(index, t)
- Parameters
index –
PySide.QtCore.int
t –
PySide.QtCore.double
Adds a new control point to a closed shape (see isCurveFinished()
).
The index is the index of the Bezier segment linking the control points at index and index + 1.
t is a value between [0,1] indicating the distance from the control point index the new control point should be.
The closer to 1 t is, the closer the new control point will be to the control point at index +1.
By default the feather point attached to this point will be equivalent to the control point.
If the auto-keying is enabled in the user interface, then this function will set a keyframe at the timeline’s current time for this shape.
- NatronEngine.BezierCurve.getActivatedParam()
- Return type
BooleanParam
Returns the Param controlling the enabled state of the Bezier.
- NatronEngine.BezierCurve.getColor(time)
- Parameters
time –
int
- Return type
Returns the value of the color parameter at the given time as an [R,G,B,A] tuple. Note that alpha will always be 1.
- NatronEngine.BezierCurve.getColorParam()
- Return type
ColorParam
Returns the Param controlling the color of the Bezier.
- NatronEngine.BezierCurve.getCompositingOperator()
- Return type
Returns the blending mode for this shape. Type help(NatronEngine.BezierCurve.CairoOperatorEnum) to see the different values possible.
- NatronEngine.BezierCurve.getCompositingOperatorParam()
- Return type
NatronEngine.ChoiceParam
Returns the Param controlling the blending mode of the Bezier.
- NatronEngine.BezierCurve.getControlPointPosition(index, time)
- Parameters
index –
int
time –
float
- Return type
PyTuple
Returns a tuple with the position of the control point at the given index as well as the position of its left and right tangents.
The tuple is encoded as such:
(x,y, leftTangentX, leftTangentY, rightTangentX, rightTangentY)
The position of the left and right tangents is absolute and not relative to (x,y).
The index passed to the function must be between 0 and getNumControlPoints
-1.
The time passed to the function corresponds to a time on the timeline’s in frames.
If it lands on a keyframe of the Bezier shape, then the position at that keyframe is returned,
otherwise the position is sampled between the surrounding keyframes.
To get a list of all keyframes time for a Bezier call the function getKeyframes()
.
- NatronEngine.BezierCurve.getFeatherDistance(time)
- Parameters
time –
int
- Return type
float
Returns the feather distance of this shape at the given time.
- NatronEngine.BezierCurve.getFeatherDistanceParam()
- Return type
NatronEngine.DoubleParam
Returns the Param controlling the feather distance of the Bezier.
- NatronEngine.BezierCurve.getFeatherFallOff(time)
- Parameters
time –
int
- Return type
float
Returns the feather fall-off of this shape at the given time.
- NatronEngine.BezierCurve.getFeatherFallOffParam()
- Return type
DoubleParam
Returns the Param controlling the color of the Bezier.
- NatronEngine.BezierCurve.getFeatherPointPosition(index, time)
- Parameters
index –
int
time –
float
- Return type
PyTuple
Returns a tuple with the position of the feather point at the given index as well as the position of its left and right tangents.
The tuple is encoded as such:
(x,y, leftTangentX, leftTangentY, rightTangentX, rightTangentY)
The position of the left and right tangents is absolute and not relative to (x,y).
The index passed to the function must be between 0 and getNumControlPoints
-1.
The time passed to the function corresponds to a time on the timeline’s in frames.
If it lands on a keyframe of the Bezier shape, then the position at that keyframe is returned,
otherwise the position is sampled between the surrounding keyframes.
To get a list of all keyframes time for a Bezier call the function getKeyframes()
.
- NatronEngine.BezierCurve.getIsActivated(time)
- Parameters
time –
int
- Return type
bool
Returns whether the curve is enabled or not at the given time. When not activated the curve will not be rendered at all in the image.
- NatronEngine.BezierCurve.getKeyframes()
- Return type
PyList
Returns a list of all keyframes set on the Bezier animation.
- NatronEngine.BezierCurve.getNumControlPoints()
- Return type
int
Returns the number of control points for this shape.
- NatronEngine.BezierCurve.getOpacity(time)
- Parameters
time –
int
- Return type
float
Returns the opacity of the curve at the given time.
- NatronEngine.BezierCurve.getOpacityParam()
- Return type
DoubleParam
Returns the Param controlling the opacity of the Bezier.
- NatronEngine.BezierCurve.getOverlayColor()
- Return type
Returns the overlay color of this shape as a [R,G,B,A] tuple. Alpha will always be 1.
- NatronEngine.BezierCurve.isCurveFinished()
- Return type
bool
Returns whether the curve is finished or not. A finished curve will have a Bezier segment between the last control point and the first control point and the Bezier will be rendered in the image.
- NatronEngine.BezierCurve.moveFeatherByIndex(index, time, dx, dy)
- Parameters
index –
int
time –
int
dx –
float
dy –
float
Moves the feather point at the given index (zero-based) by the given delta (dx,dy). The time parameter is given so that if auto-keying is enabled a new keyframe will be set.
- NatronEngine.BezierCurve.moveLeftBezierPoint(index, time, dx, dy)
- Parameters
index –
int
time –
int
dx –
float
dy –
float
Moves the left Bezier point of the control point at the given index by the given delta. The time parameter is given so that if auto-keying is enabled a new keyframe will be set.
- NatronEngine.BezierCurve.movePointByIndex(index, time, dx, dy)
- Parameters
index –
int
time –
int
dx –
float
dy –
float
Moves the point at the given index (zero-based) by the given delta (dx,dy). The time parameter is given so that if auto-keying is enabled a new keyframe will be set.
- NatronEngine.BezierCurve.moveRightBezierPoint(index, time, dx, dy)
- Parameters
index –
int
time –
int
dx –
float
dy –
float
Moves the right Bezier point at the given index (zero-based) by the given delta (dx,dy). The time parameter is given so that if auto-keying is enabled a new keyframe will be set.
- NatronEngine.BezierCurve.removeControlPointByIndex(index)
- Parameters
index –
int
Removes the control point at the given index (zero-based).
- NatronEngine.BezierCurve.setActivated(time, activated)
- Parameters
time –
int
activated –
bool
Set a new keyframe for the activated parameter at the given time
- NatronEngine.BezierCurve.setColor(time, r, g, b)
- Parameters
time –
int
r –
float
g –
float
b –
float
Set a new keyframe for the color parameter at the given time
- NatronEngine.BezierCurve.setCompositingOperator(op)
- Parameters
Set the compositing operator for this shape.
- NatronEngine.BezierCurve.setCurveFinished(finished)
- Parameters
finished –
bool
Set whether the curve should be finished or not. See isCurveFinished()
- NatronEngine.BezierCurve.setFeatherDistance(dist, time)
- Parameters
dist –
float
time –
int
Set a new keyframe for the feather distance parameter at the given time
- NatronEngine.BezierCurve.setFeatherFallOff(falloff, time)
- Parameters
falloff –
float
time –
int
Set a new keyframe for the feather fall-off parameter at the given time
- NatronEngine.BezierCurve.setFeatherPointAtIndex(index, time, x, y, lx, ly, rx, ry)
- Parameters
index –
int
time –
int
x –
float
y –
float
lx –
float
ly –
float
rx –
float
ry –
float
Set the feather point at the given index at the position (x,y) with the left Bezier point at (lx,ly) and right Bezier point at (rx,ry).
The time parameter is given so that if auto-keying is enabled a new keyframe will be set.
- NatronEngine.BezierCurve.setOpacity(opacity, time)
- Parameters
opacity –
float
time –
int
Set a new keyframe for the opacity parameter at the given time
- NatronEngine.BezierCurve.setOverlayColor(r, g, b)
- Parameters
r –
float
g –
float
b –
float
Set the overlay color of this shape
- NatronEngine.BezierCurve.setPointAtIndex(index, time, x, y, lx, ly, rx, ry)
- Parameters
index –
int
time –
int
x –
float
y –
float
lx –
float
ly –
float
rx –
float
ry –
float
Set the point at the given index at the position (x,y) with the left Bezier point at (lx,ly) and right Bezier point at (rx,ry).
The time parameter is given so that if auto-keying is enabled a new keyframe will be set.