return Math.abs(b - a) < (threshold || 1e-6)
}
+function isMatrixLike (o) {
+ return (
+ o.a != null ||
+ o.b != null ||
+ o.c != null ||
+ o.d != null ||
+ o.e != null ||
+ o.f != null
+ )
+}
+
// TODO: Refactor this to a static function of matrix.js
function formatTransforms (o) {
// Get all of the parameters required to form the matrix
source = source instanceof SVG.Element ? source.matrixify()
: typeof source === 'string' ? arrayToMatrix(source.split(SVG.regex.delimiter).map(parseFloat))
: Array.isArray(source) ? arrayToMatrix(source)
- : (typeof source === 'object' && (
- source.a != null || source.b != null || source.c != null ||
- source.d != null || source.e != null || source.f != null
- )) ? source
+ : (typeof source === 'object' && isMatrixLike(source)) ? source
: (typeof source === 'object') ? new SVG.Matrix().transform(source)
: arguments.length === 6 ? arrayToMatrix([].slice.call(arguments))
: base
return decomposed[o] || decomposed
}
- // Set the origin according to the defined transform
- o = {...o, origin: getOrigin(o, this)}
+ if (!isMatrixLike(o)) {
+ // Set the origin according to the defined transform
+ o = {...o, origin: getOrigin(o, this)}
+ }
// The user can pass a boolean, an SVG.Element or an SVG.Matrix or nothing
var cleanRelative = relative === true ? this : (relative || false)