2012-08-10 15:14:56 +00:00
|
|
|
(function(){
|
|
|
|
|
|
|
|
|
|
QUnit.module('fabric.Color');
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('constructor', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ff5555');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), 'FF5555');
|
2012-08-10 15:14:56 +00:00
|
|
|
|
2015-04-23 09:47:23 +00:00
|
|
|
oColor = new fabric.Color('rgb(100,100,100)');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgb(), 'rgb(100,100,100)');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
|
2015-04-23 09:47:23 +00:00
|
|
|
oColor = new fabric.Color('rgba(100,100,100, 0.5)');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(100,100,100,0.5)');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
|
2015-04-23 09:47:23 +00:00
|
|
|
oColor = new fabric.Color('hsl(262,80%,12%)');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHsl(), 'hsl(262,80%,12%)');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('empty args', function(assert) {
|
2013-11-22 16:30:55 +00:00
|
|
|
var oColor = new fabric.Color();
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), '000000');
|
2013-11-22 16:30:55 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('getSource', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.getSource === 'function');
|
|
|
|
|
assert.deepEqual(oColor.getSource(), [255, 255, 255, 1]);
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('setSource', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.setSource === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([0,0,0,1]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.deepEqual(oColor.getSource(), [0,0,0,1]);
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toRgb', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toRgb === 'function');
|
|
|
|
|
assert.equal(oColor.toRgb(), 'rgb(255,255,255)');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([0,0,0,0.5]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toRgb(), 'rgb(0,0,0)');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toRgba', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toRgba === 'function');
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,1)');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([0,0,0,0.5]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toRgba(), 'rgba(0,0,0,0.5)');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toHsl', function(assert) {
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toHsl === 'function');
|
|
|
|
|
assert.equal(oColor.toHsl(), 'hsl(0,0%,100%)');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
oColor.setSource([0,0,0,0.5]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHsl(), 'hsl(0,0%,0%)');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toHsla', function(assert) {
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toHsla === 'function');
|
|
|
|
|
assert.equal(oColor.toHsla(), 'hsla(0,0%,100%,1)');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
oColor.setSource([0,0,0,0.5]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHsla(), 'hsla(0,0%,0%,0.5)');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toHex', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toHex === 'function');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([0,0,0,0.5]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHex(), '000000');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toHexa', function(assert) {
|
2017-01-09 13:22:31 +00:00
|
|
|
var oColor = new fabric.Color('ffffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toHexa === 'function');
|
|
|
|
|
assert.equal(oColor.toHexa(), 'FFFFFFFF');
|
2017-12-27 09:05:40 +00:00
|
|
|
oColor.setSource([255,255,255,0.1]);
|
|
|
|
|
assert.equal(oColor.toHexa(), 'FFFFFF1A');
|
2017-01-09 13:22:31 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('getAlpha', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.getAlpha === 'function');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 1);
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([10,20,30, 0.456]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.getAlpha(), 0.456);
|
2017-01-09 13:22:31 +00:00
|
|
|
oColor = new fabric.Color('ffffffcc');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.getAlpha(), 0.8);
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('setAlpha', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ffffff');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.setAlpha === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setAlpha(0.1234);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.getAlpha(), 0.1234);
|
|
|
|
|
assert.equal(oColor.setAlpha(0), oColor, 'should be chainable');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toGrayscale', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('ff5555');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toGrayscale === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.toGrayscale();
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHex(), '888888');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([10, 20, 30, 1]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toGrayscale(), oColor, 'should be chainable');
|
|
|
|
|
assert.equal(oColor.toHex(), '121212');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('toBlackWhite', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('333333');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.toBlackWhite === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.toBlackWhite();
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHex(), '000000');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([200,200,200,1]);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toBlackWhite(), oColor, 'should be chainable');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.setSource([127,127,127,1]);
|
|
|
|
|
oColor.toBlackWhite(200);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHex(), '000000', 'should work with threshold');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgb', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgb === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
var originalRgb = 'rgb(255,255,255)';
|
|
|
|
|
var oColor = fabric.Color.fromRgb(originalRgb);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgb(), originalRgb);
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgb (with whitespaces)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgb === 'function');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalRgb = 'rgb( 255 , 255 , 255 )';
|
|
|
|
|
var oColor = fabric.Color.fromRgb(originalRgb);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgb(), 'rgb(255,255,255)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgb (percentage values)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgb === 'function');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalRgb = 'rgb(100%,100%,100%)';
|
|
|
|
|
var oColor = fabric.Color.fromRgb(originalRgb);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgb(), 'rgb(255,255,255)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgb (percentage values with whitespaces)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgb === 'function');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalRgb = 'rgb( 100% , 100% , 100% )';
|
|
|
|
|
var oColor = fabric.Color.fromRgb(originalRgb);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgb(), 'rgb(255,255,255)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2018-06-02 18:12:38 +00:00
|
|
|
QUnit.test('fromRgb (uppercase)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgb === 'function');
|
|
|
|
|
var originalRgb = 'RGB(255,255,255)';
|
|
|
|
|
var oColor = fabric.Color.fromRgb(originalRgb);
|
|
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('fromRgba (uppercase)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgba === 'function');
|
|
|
|
|
var originalRgba = 'RGBA(255,255,255,0.5)';
|
|
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
|
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly');
|
|
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgba', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromRgba === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
var originalRgba = 'rgba(255,255,255,0.5)';
|
|
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), originalRgba);
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgba (with missing 0)', function(assert) {
|
2017-06-14 19:50:27 +00:00
|
|
|
var originalRgba = 'rgba( 255 , 255 , 255 , .3 )';
|
|
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,0.3)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.3, 'alpha should be set properly');
|
2017-06-14 19:50:27 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgba (with whitespaces)', function(assert) {
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalRgba = 'rgba( 255 , 255 , 255 , 0.5 )';
|
2015-04-23 09:47:23 +00:00
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,0.5)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgba (percentage values)', function(assert) {
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalRgba = 'rgba(100%,100%,100%,0.5)';
|
2015-04-23 09:47:23 +00:00
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,0.5)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgba (percentage values with whitespaces)', function(assert) {
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalRgba = 'rgba( 100% , 100% , 100% , 0.5 )';
|
2015-04-23 09:47:23 +00:00
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,0.5)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromRgba (percentage values with decimals)', function(assert) {
|
2014-02-27 09:19:42 +00:00
|
|
|
var originalRgba = 'rgba( 100.00%, 100.00%, 100.00% , 0.5 )';
|
2015-04-23 09:47:23 +00:00
|
|
|
var oColor = fabric.Color.fromRgba(originalRgba);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,0.5)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.5, 'alpha should be set properly');
|
2014-02-27 09:19:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromHsl', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHsl === 'function');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalHsl = 'hsl(262,80%,12%)';
|
|
|
|
|
var oColor = fabric.Color.fromHsl(originalHsl);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHsl(), originalHsl);
|
|
|
|
|
assert.equal(oColor.toHex(), '180637');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromHsl (with whitespaces)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHsl === 'function');
|
2013-05-25 17:42:31 +00:00
|
|
|
var originalHsl = 'hsl( 262 , 80% , 12% )';
|
|
|
|
|
var oColor = fabric.Color.fromHsl(originalHsl);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHsl(), 'hsl(262,80%,12%)');
|
|
|
|
|
assert.equal(oColor.toHex(), '180637');
|
2013-05-25 17:42:31 +00:00
|
|
|
});
|
|
|
|
|
|
2018-06-02 18:12:38 +00:00
|
|
|
QUnit.test('fromHsl (uppercase)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHsl === 'function');
|
|
|
|
|
var originalHsl = 'HSL(270,50%,40%)';
|
|
|
|
|
var oColor = fabric.Color.fromHsl(originalHsl);
|
|
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), '663399');
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(102,51,153,1)');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('fromHsla (uppercase)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHsla === 'function');
|
|
|
|
|
var originalHsla = 'HSLA(108,50%,50%,0.7)';
|
|
|
|
|
var oColor = fabric.Color.fromHsla(originalHsla);
|
|
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), '59BF40');
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(89,191,64,0.7)');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.7, 'alpha should be set properly');
|
|
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromHsla', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHsla === 'function');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
var originalHsla = 'hsla(262,80%,12%,0.2)';
|
|
|
|
|
var oColor = fabric.Color.fromHsla(originalHsla);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHsla(), originalHsla);
|
|
|
|
|
assert.equal(oColor.toHex(), '180637');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.2, 'alpha should be set properly');
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromHsla (with whitespaces)', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHsla === 'function');
|
2013-05-25 17:42:31 +00:00
|
|
|
var originalHsla = 'hsla( 262 , 80% , 12% , 0.2 )';
|
|
|
|
|
var oColor = fabric.Color.fromHsla(originalHsla);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHsla(), 'hsla(262,80%,12%,0.2)');
|
|
|
|
|
assert.equal(oColor.toHex(), '180637');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.2, 'alpha should be set properly');
|
2013-05-25 17:42:31 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('fromHex', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromHex === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
var originalHex = 'FF5555';
|
|
|
|
|
var oColor = fabric.Color.fromHex(originalHex);
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toHex(), originalHex);
|
|
|
|
|
assert.equal(oColor.toRgb(), 'rgb(255,85,85)');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('sourceFromRgb', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.sourceFromRgb === 'function');
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromRgb('rgb(255,255,255)'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromRgb('rgb(100,150,200)'), [100,150,200,1]);
|
Parse SVG stroke-opacity and fill-opacity
- SVG attribute opacity is now used for object's opacity
- fill-opacity and stroke-opacity are added to stroke and fill color value
- Add hsl/hsla support (e.g. hsl(270, 80%, 10%), hsla(320, 10%, 66%, 0.5))
- Add support for rgb/rgba values with whitespaces around values (e.g. rgba( 255 , 100 , 50 , 0.1 )) and percentage values (e.g. rgb(100%, 67%, 15%, 0.8))
- Delete stroke and strokeWidth from fabric.Text (defined in fabric.Object)
- New unit test for parse stroke-opacity and fill-opacity
- Update unit tests (new tests for hsl/hsla and rgb/rgba (whitespaces and percentage values))
- Change equal and deepEqual parameter order (e.g. equal(actualValue, expectedValue, message))
- Doc additions
2013-05-25 09:03:09 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('sourceFromHsl', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.sourceFromHsl === 'function');
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHsl('hsl(360,100%,100%)'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHsl('hsl(180,50%,40%)'), [51,153,153,1]);
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('sourceFromHex', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.sourceFromHex === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
|
|
|
|
|
// uppercase
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFFFF00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFFFFCC'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFFFFFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFFFF00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFFFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFFC'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFF0'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#FFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFFFF00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFFFFCC'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFFFFFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFFFF00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFFFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFF'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFFC'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFF0'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('FFF'), [255,255,255,1]);
|
2012-08-10 15:14:56 +00:00
|
|
|
|
|
|
|
|
// lowercase
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#ffffff00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#ffffffcc'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#ffffffff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#ffffff00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#ffffff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#ffff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#fffc'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#fff0'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('#fff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('ffffff00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('ffffffcc'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('ffffffff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('ffffff00'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('ffffff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('ffff'), [255,255,255,1]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('fffc'), [255,255,255,0.8]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('fff0'), [255,255,255,0]);
|
|
|
|
|
assert.deepEqual(fabric.Color.sourceFromHex('fff'), [255,255,255,1]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
QUnit.test('fromSource', function(assert) {
|
|
|
|
|
assert.ok(typeof fabric.Color.fromSource === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = fabric.Color.fromSource([255,255,255,0.37]);
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(oColor);
|
|
|
|
|
assert.ok(oColor instanceof fabric.Color);
|
|
|
|
|
assert.equal(oColor.toRgba(), 'rgba(255,255,255,0.37)');
|
|
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
|
|
|
|
assert.equal(oColor.getAlpha(), 0.37);
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
|
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('overlayWith', function(assert) {
|
2012-08-10 15:14:56 +00:00
|
|
|
var oColor = new fabric.Color('FF0000');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.ok(typeof oColor.overlayWith === 'function');
|
2012-08-10 15:14:56 +00:00
|
|
|
oColor.overlayWith('FFFFFF');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHex(), 'FF8080');
|
2012-08-10 15:14:56 +00:00
|
|
|
|
|
|
|
|
oColor = new fabric.Color('FFFFFF');
|
|
|
|
|
oColor.overlayWith('FFFFFF');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toHex(), 'FFFFFF');
|
2012-08-10 15:14:56 +00:00
|
|
|
|
|
|
|
|
oColor = new fabric.Color('rgb(255,255,255)');
|
|
|
|
|
oColor.overlayWith('rgb(0,0,0)');
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toRgb(), 'rgb(128,128,128)');
|
2012-08-10 15:14:56 +00:00
|
|
|
|
|
|
|
|
oColor = new fabric.Color('rgb(255,255,255)');
|
|
|
|
|
oColor.overlayWith(new fabric.Color('rgb(0,0,0)'));
|
2017-09-17 09:44:57 +00:00
|
|
|
assert.equal(oColor.toRgb(), 'rgb(128,128,128)');
|
2012-08-10 15:14:56 +00:00
|
|
|
});
|
2014-05-09 20:43:47 +00:00
|
|
|
|
2017-09-17 09:44:57 +00:00
|
|
|
QUnit.test('transparent', function(assert) {
|
|
|
|
|
assert.deepEqual(new fabric.Color('transparent').getSource(), [255,255,255,0]);
|
2014-05-09 20:43:47 +00:00
|
|
|
});
|
2013-11-22 16:30:55 +00:00
|
|
|
})();
|