1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
require 'es6-shim'
vows = require 'vows'
assert = require 'assert'
chroma = require '../chroma'
vows
.describe('Testing lightess correction')
.addBatch
'simple two color linear interpolation':
topic: -> chroma.scale(['white', 'black']).mode('lab')
'center L is 50': (topic) ->
assert.equal Math.round(topic(0.5).lab()[0]), 50
'hot - w/o correction':
topic: -> chroma.scale(['white', 'yellow', 'red', 'black']).mode('lab')
'center L is 74': (topic) ->
assert.equal Math.round(topic(0.5).lab()[0]), 74
'hot - with correction':
topic: -> chroma.scale(['white', 'yellow', 'red', 'black']).mode('lab').correctLightness(true)
'center L is 50': (topic) ->
assert.equal Math.round(topic(0.5).lab()[0]), 50
'hot - w/o correction - domained [0,100]':
topic: -> chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,100]).mode('lab')
'center L is 74': (topic) ->
assert.equal Math.round(topic(50).lab()[0]), 74
'hot - with correction - domained [0,100]':
topic: -> chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,100]).mode('lab').correctLightness(true)
'center L is 50': (topic) ->
assert.equal Math.round(topic(50).lab()[0]), 50
'hot - w/o correction - domained [0,20,40,60,80,100]':
topic: -> chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,20,40,60,80,100]).mode('lab')
'center L is 74': (topic) ->
assert.equal Math.round(topic(50).lab()[0]), 74
'hot - with correction - domained [0,20,40,60,80,100]':
topic: -> chroma.scale(['white', 'yellow', 'red', 'black']).domain([0,20,40,60,80,100]).mode('lab').correctLightness(true)
'center L is 50': (topic) ->
console.log '---'
assert.equal Math.round(topic(50).lab()[0]), 50
.export(module)
|