diff options
author | wout <wout@impinc.co.uk> | 2014-01-31 16:22:01 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-01-31 16:22:01 +0100 |
commit | 2b2a4040f69fde2fb6555c663da8ef6235639dd0 (patch) | |
tree | 522edabba7b250ff7fa31011213a98e95786e59e /spec | |
parent | b095d2949b24da056a0d968e0f2ba306d0d1f48d (diff) | |
download | svg.js-2b2a4040f69fde2fb6555c663da8ef6235639dd0.tar.gz svg.js-2b2a4040f69fde2fb6555c663da8ef6235639dd0.zip |
Added morph() and at() methods to SVG.Color
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/color.js | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/spec/spec/color.js b/spec/spec/color.js index ca74bca..526b544 100644 --- a/spec/spec/color.js +++ b/spec/spec/color.js @@ -1,24 +1,66 @@ describe('Color', function() { + var color + + beforeEach(function() { + color = new SVG.Color({ r: 0, g: 102, b: 255 }) + }) it('correclty parses a rgb string', function() { - var color = new SVG.Color('rgb(255,0,128)') + color = new SVG.Color('rgb(255,0,128)') expect(color.r).toBe(255) expect(color.g).toBe(0) expect(color.b).toBe(128) }) it('correclty parses a 3 digit hex string', function() { - var color = new SVG.Color('#f06') + color = new SVG.Color('#f06') expect(color.r).toBe(255) expect(color.g).toBe(0) expect(color.b).toBe(102) }) it('correclty parses a 6 digit hex string', function() { - var color = new SVG.Color('#0066ff') + color = new SVG.Color('#0066ff') expect(color.r).toBe(0) expect(color.g).toBe(102) expect(color.b).toBe(255) }) -})
\ No newline at end of file + describe('toHex()', function() { + it('returns a hex color', function() { + expect(color.toHex()).toBe('#0066ff') + }) + }) + + describe('toRgb()', function() { + it('returns a rgb string color', function() { + expect(color.toRgb()).toBe('rgb(0,102,255)') + }) + }) + + describe('brightness()', function() { + it('returns the percieved brightness value of a color', function() { + expect(color.brightness()).toBe(0.346) + }) + }) + + describe('morph()', function() { + it('prepares the color for morphing', function() { + var destination = new SVG.Color + color.morph(destination) + expect(color.destination).toEqual(destination) + }) + }) + + describe('at()', function() { + it('morphes color to a given position', function() { + var destination = new SVG.Color + var morphed = color.morph(destination).at(0.5) + expect(morphed.r).toBe(0) + expect(morphed.g).toBe(51) + expect(morphed.b).toBe(127) + }) + }) + +}) + |