Skip to content

Commit

Permalink
Merge ff3c04f into 58d3c2c
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryGogonis committed Jul 14, 2017
2 parents 58d3c2c + ff3c04f commit 192018e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class Matrix extends Map {
}
}

static fromCTM(ctm) {
const {a, b, c, d, e, f} = ctm
return new Matrix(a,b,c,d,e,f)
}

/**
* Multiplies current matrix with new matrix values.
* @param {number} a2 - scale x
Expand Down
15 changes: 15 additions & 0 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,18 @@ describe('#applyToPoint', () => {
expect(new Matrix().applyToPoint(x, y)).toEqual({x, y})
})
})

describe('fromCTM', () => {
it('should return a new Matrix', () => {
const actual = Matrix.fromCTM({
a: 1,
b: 2,
c: 3,
d: 4,
e: 5,
f: 6
})
const expected = new Matrix(1, 2, 3, 4, 5, 6)
expect(actual).toEqual(expected)
})
})

0 comments on commit 192018e

Please sign in to comment.