-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When building a mutator, accept the warp data to make benders. But don't apply them to the master and instance locations. Add test file from @anthrotype
- Loading branch information
Showing
2 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from mutatorMath.objects.mutator import buildMutator | ||
from mutatorMath.objects.location import Location | ||
|
||
# source locations implicitly specified in internal, design location. | ||
# the second item is master's value at given location. I use numbers for simplicity | ||
# but it can be any object that supports addition and multiplication (fontMath objects) | ||
masters = [ | ||
(Location(Width=70), 0), | ||
(Location(Width=100), 100), | ||
] | ||
|
||
axes = { | ||
'Width': { | ||
'tag': 'wdth', | ||
'name': 'Width', | ||
# min/default/max are always in user-space coordinates | ||
'minimum': 62.5, | ||
'default': 100.0, | ||
'maximum': 100.0, | ||
# first item (input) is user-space coordinate, second item (output) is internal design coordinate | ||
'map': [(62.5, 70.0), (75.0, 79.0), (87.5, 89.0), (100.0, 100.0)], | ||
#'map': [(70.0, 62.5), (79.0, 75.0), (89.0, 87.5), (100.0, 100.0)], | ||
} | ||
} | ||
|
||
_, mut = buildMutator(masters, axes) | ||
|
||
# instance locations are also specified in internal design coordinates (at least varLib assumes they are) | ||
instance_location = Location(Width=79) | ||
|
||
instance = mut.makeInstance(Location(Width=79), bend=False) | ||
# the result is 27.642276422764223, but it should have been 30.0 | ||
print(instance) | ||
|
||
instance = mut.makeInstance(Location(Width=75), bend=True) | ||
# the result is 27.642276422764223, but it should have been 30.0 | ||
print(instance) |