Skip to content

Commit

Permalink
feat: isIdentity
Browse files Browse the repository at this point in the history
  • Loading branch information
HarryGogonis committed Jun 25, 2017
1 parent c18f6e2 commit 4d39263
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ class Matrix extends Map {
)
}

/**
* @return {boolean} true if identity (no transforms applied)
*/
isIdentity () {
return this.get('a') === 1
&& this.get('b') === 0
&& this.get('c') === 0
&& this.get('d') === 1
&& this.get('e') === 0
&& this.get('f') === 0
}

/**
* @return {string}
*/
Expand Down
5 changes: 5 additions & 0 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ describe('multiply', () => {
})
})

describe('isIdentity', () => {
expect(mockMatrix.isIdentity()).toBe(false)
expect(new Matrix().isIdentity()).toBe(true)
})

describe('toString', () => {
it('should return a matrix string', () => {
let str = mockMatrix.toString()
Expand Down

0 comments on commit 4d39263

Please sign in to comment.