Fix multiplication of numpy matrices -- need to use .dot() instead of operator*
parent
1c8ca10f73
commit
29eb1e9364
|
@ -113,7 +113,7 @@ def flatten_all_paths(
|
|||
StackElement = collections.namedtuple('StackElement', ['group', 'transform'])
|
||||
|
||||
def new_stack_element(element, last_tf):
|
||||
return StackElement(element, last_tf * parse_transform(element.get('transform')))
|
||||
return StackElement(element, last_tf.dot(parse_transform(element.get('transform'))))
|
||||
|
||||
def get_relevant_children(parent, last_tf):
|
||||
children = []
|
||||
|
@ -133,7 +133,7 @@ def flatten_all_paths(
|
|||
# the path_filter accepts it.
|
||||
for key, converter in path_conversions.iteritems():
|
||||
for path_elem in filter(path_filter, top.group.iterfind('svg:'+key, SVG_NAMESPACE)):
|
||||
path_tf = top.transform * parse_transform(path_elem.get('transform'))
|
||||
path_tf = top.transform.dot(parse_transform(path_elem.get('transform')))
|
||||
path = transform(parse_path(converter(path_elem)), path_tf)
|
||||
paths.append(FlattenedPath(path, path_elem.attrib, path_tf))
|
||||
|
||||
|
|
|
@ -257,8 +257,10 @@ def _parse_transform_substr(transform_substr):
|
|||
tf_offset[0:2, 2:3] = np.matrix([[offset[0]], [offset[1]]])
|
||||
tf_rotate = np.identity(3)
|
||||
tf_rotate[0:2, 0:2] = np.matrix([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
|
||||
tf_offset_neg = np.identity(3)
|
||||
tf_offset_neg[0:2, 2:3] = np.matrix([[-offset[0]], [-offset[1]]])
|
||||
|
||||
transform = tf_offset * tf_rotate * (-tf_offset)
|
||||
transform = tf_offset.dot(tf_rotate).dot(tf_offset_neg)
|
||||
|
||||
elif 'skewX' in transform_substr:
|
||||
if not _check_num_parsed_values(values, [1]):
|
||||
|
@ -289,6 +291,6 @@ def parse_transform(transform_str):
|
|||
total_transform = np.identity(3)
|
||||
transform_substrs = transform_str.split(')')[:-1] # Skip the last element, because it should be empty
|
||||
for substr in transform_substrs:
|
||||
total_transform *= _parse_transform_substr(substr)
|
||||
total_transform = total_transform.dot(_parse_transform_substr(substr))
|
||||
|
||||
return total_transform
|
||||
|
|
Loading…
Reference in New Issue