Use Color objects for colors

This commit is contained in:
MoyuScript
2014-12-13 18:10:41 +02:00
parent 068151cc91
commit 15dd95c15c
11 changed files with 198 additions and 147 deletions

View File

@ -16,11 +16,13 @@
it("bisque", function () {
var c = new Color("bisque");
assertColor(c, 255, 228, 196, null);
expect(c.isTransparent()).to.equal(false);
});
it("BLUE", function () {
var c = new Color("BLUE");
assertColor(c, 0, 0, 255, null);
expect(c.isTransparent()).to.equal(false);
});
});
@ -28,33 +30,39 @@
it("rgb(1,3,5)", function () {
var c = new Color("rgb(1,3,5)");
assertColor(c, 1, 3, 5, null);
expect(c.isTransparent()).to.equal(false);
});
it("rgb(222, 111, 50)", function () {
var c = new Color("rgb(222, 111, 50)");
assertColor(c, 222, 111, 50, null);
expect(c.isTransparent()).to.equal(false);
});
it("rgb( 222, 111 , 50)", function () {
var c = new Color("rgb(222 , 111 , 50)");
assertColor(c, 222, 111, 50, null);
expect(c.isTransparent()).to.equal(false);
});
});
describe("rgba()", function() {
it("rgba(200,3,5,0)", function () {
var c = new Color("rgba(200,3,5,0)");
assertColor(c, 200, 3, 5, 0);
it("rgba(200,3,5,1)", function () {
var c = new Color("rgba(200,3,5,1)");
assertColor(c, 200, 3, 5, 1);
expect(c.isTransparent()).to.equal(false);
});
it("rgba(222, 111, 50, 0.22)", function () {
var c = new Color("rgba(222, 111, 50, 0.22)");
assertColor(c, 222, 111, 50, 0.22);
expect(c.isTransparent()).to.equal(false);
});
it("rgba( 222, 111 , 50, 0.123 )", function () {
var c = new Color("rgba(222 , 111 , 50, 0.123)");
assertColor(c, 222, 111, 50, 0.123);
expect(c.isTransparent()).to.equal(false);
});
});
@ -62,16 +70,33 @@
it("#7FFFD4", function () {
var c = new Color("#7FFFD4");
assertColor(c, 127, 255, 212, null);
expect(c.isTransparent()).to.equal(false);
});
it("#f0ffff", function () {
var c = new Color("#f0ffff");
assertColor(c, 240, 255, 255, null);
expect(c.isTransparent()).to.equal(false);
});
it("#fff", function () {
var c = new Color("#fff");
assertColor(c, 255, 255, 255, null);
expect(c.isTransparent()).to.equal(false);
});
});
describe("transparency", function() {
it("transparent", function () {
var c = new Color("transparent");
assertColor(c, 0, 0, 0, 0);
expect(c.isTransparent()).to.equal(true);
});
it("rgba(255,255,255,0)", function () {
var c = new Color("rgba(255,255,255,0)");
assertColor(c, 255, 255, 255, 0);
expect(c.isTransparent()).to.equal(true);
});
});
});

View File

@ -12,7 +12,7 @@ var h2cSelector, h2cOptions;
}
var sources = ['log', 'punycode/punycode', 'core', 'nodecontainer', 'pseudoelementcontainer', 'stackingcontext', 'textcontainer', 'support', 'imagecontainer', 'dummyimagecontainer', 'proxyimagecontainer', 'gradientcontainer',
'lineargradientcontainer', 'webkitgradientcontainer', 'svgcontainer', 'svgnodecontainer', 'imageloader', 'nodeparser', 'font', 'fontmetrics', 'renderer', 'promise', 'xhr', 'framecontainer', 'proxy', 'renderers/canvas'];
'lineargradientcontainer', 'webkitgradientcontainer', 'svgcontainer', 'svgnodecontainer', 'imageloader', 'nodeparser', 'font', 'fontmetrics', 'renderer', 'promise', 'xhr', 'framecontainer', 'proxy', 'color', 'renderers/canvas'];
['/tests/assets/jquery-1.6.2'].concat(window.location.search === "?selenium" ? ['/dist/html2canvas'] : sources.map(function(src) { return '/src/' + src; })).forEach(appendScript);