diff options
author | Martin Ashby <martin@martin-laptop.lan> | 2018-05-17 20:17:01 +0100 |
---|---|---|
committer | Martin Ashby <martin@martin-laptop.lan> | 2018-05-17 20:17:01 +0100 |
commit | 10e7ce5764b3b456e1f909cd6b6a90f076c2e014 (patch) | |
tree | d9344bfa3e271ef179b2ea969c27bf4b39bfe260 /src/Utils.test.js | |
parent | e9ee34abf84a10911b2c6041534c2df7f91f052a (diff) | |
download | unicornpaint-10e7ce5764b3b456e1f909cd6b6a90f076c2e014.tar.gz unicornpaint-10e7ce5764b3b456e1f909cd6b6a90f076c2e014.tar.bz2 unicornpaint-10e7ce5764b3b456e1f909cd6b6a90f076c2e014.tar.xz unicornpaint-10e7ce5764b3b456e1f909cd6b6a90f076c2e014.zip |
Fixed rotation problem. Added rotate function. Added docker file
Diffstat (limited to 'src/Utils.test.js')
-rw-r--r-- | src/Utils.test.js | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/Utils.test.js b/src/Utils.test.js index 6c9161b..33d63f0 100644 --- a/src/Utils.test.js +++ b/src/Utils.test.js @@ -1,4 +1,4 @@ -import { colorEqual, coordsEqual, xy, rgb, findContiguousPixels } from './Utils' +import { colorEqual, coordsEqual, xy, rgb, findContiguousPixels, rotatePixelsClock, rotatePixelsCounterClock } from './Utils' test('test colorEqual function', () => { expect(colorEqual([0, 0, 0], [0, 0, 0])) @@ -78,4 +78,38 @@ test('contiguousPixels', () => { [[0, 0, 1], [0, 0, 1], [0, 0, 1], [0, 0, 1]] ]).length) .toBe(4) +}) + +test('rotate clockwise function', () => { + let rot1 = rotatePixelsClock([ + [[0, 0, 1], [0, 0, 0], [0, 0, 0], [0, 0, 2]], + [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[0, 0, 4], [0, 0, 0], [0, 0, 0], [0, 0, 3]] + ]) + expect(rot1[0][3][2]) + .toBe(1) + expect(rot1[3][3][2]) + .toBe(2) + expect(rot1[3][0][2]) + .toBe(3) + expect(rot1[0][0][2]) + .toBe(4) +}) + +test('rotate counter-clockwise function', () => { + let rot1 = rotatePixelsCounterClock([ + [[0, 0, 1], [0, 0, 0], [0, 0, 0], [0, 0, 2]], + [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]], + [[0, 0, 4], [0, 0, 0], [0, 0, 0], [0, 0, 3]] + ]) + expect(rot1[0][3][2]) + .toBe(3) + expect(rot1[3][3][2]) + .toBe(4) + expect(rot1[3][0][2]) + .toBe(1) + expect(rot1[0][0][2]) + .toBe(2) })
\ No newline at end of file |