-
Notifications
You must be signed in to change notification settings - Fork 24
/
rightTriangle.py
59 lines (36 loc) · 1.4 KB
/
rightTriangle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#This Source Code Form is subject to the terms of the Mozilla Public
#License, v. 2.0. If a copy of the MPL was not distributed with this
#file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#Created by Fabrice Fernandez on 22/07/2019.
import string
import NatronEngine
from NatronGui import *
# CREATE A RIGHT ALIGNED TRIANGLE #
def rightTriangle():
# get current Natron instance running in memory
app = natron.getGuiInstance(0)
# create a 'Roto' node
myRoto = app.createNode("fr.inria.built-in.Roto")
# set 'Roto' label
myRoto.setLabel('right_Triangle1')
# get input image size
imageWidth = myRoto.getOutputFormat().width()
imageHeight = myRoto.getOutputFormat().height()
# get roto context
rotoContext = myRoto.getRotoContext()
# get 'Base Layer'
rootLayer = rotoContext.getBaseLayer()
# create one point bezier curve at frame 1
newTriangle = rotoContext.createBezier( imageWidth , imageHeight , 1 )
newTriangle.setScriptName("right_Triangle1")
newTriangle.setLabel("right_Triangle1")
newTriangle.setLocked(False)
newTriangle.setVisible(True)
# add created bezier to 'Base Layer'
rootLayer.addItem(newTriangle)
newTriangle.addControlPoint( imageWidth , 0.0 )
newTriangle.addControlPoint( imageWidth/2 , imageHeight/2 )
newTriangle.setCurveFinished(1)
# set center position
myRoto.getParam('center').setValue(imageWidth/2,0)
myRoto.getParam('center').setValue(imageHeight/2,1)