-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimpleblend.py
executable file
·59 lines (46 loc) · 1.78 KB
/
simpleblend.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
#!/bin/env python
import os
import sys
basePath = os.path.dirname(os.path.realpath(__file__))
modulePath = basePath + "/python_modules/lib/python"
print "modulePath " + modulePath
sys.path.append( modulePath )
import defcon
import mutatorMath
import mutatorMath.ufo.document as udoc
import mutatorMath.objects.location as mmlocation
if __name__ == "__main__":
if len(sys.argv) < 4:
print "Usage: simpleblend masterA.ufo masterB.ufo weight 0.5 "
print " will create an instance 50% between both masters"
print " note that masterA will have weight set to 1.0"
print " and masterB will have weight set to 0.0"
sys.exit(2)
masterA = sys.argv[1]
masterB = sys.argv[2]
axisName = sys.argv[3]
instanceLocation = float(sys.argv[4])
exportUFOPath = "out.ufo"
if len(sys.argv) > 4:
exportUFOPath = sys.argv[5]
print "creating an instance on axis " + axisName + " that is " \
+ str(instanceLocation) + " between your masters"
print " first master: " + masterA
print "second master: " + masterB
dw = udoc.DesignSpaceDocumentWriter("simpleblend.designspace")
d = dict()
d[axisName] = 1
dw.addSource( masterA, "masterA", mmlocation.Location(d) )
d[axisName] = 0
dw.addSource( masterB, "masterB", mmlocation.Location(d) )
d[axisName] = instanceLocation
dw.startInstance( "interpolated", mmlocation.Location(d),
"familyName", "styleName", exportUFOPath )
# dw.writeGlyph("o");
dw.endInstance()
dw.save()
# make an instance instanceLocation % of the way between the two masters
dr = udoc.DesignSpaceDocumentReader("simpleblend.designspace", 2)
dr.process()
# output the instance as ufo for inspection
# (done in the above already)