Skip to content

Commit

Permalink
make normalizeColor assign default alpha value instead of validateColor
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalAr committed Nov 28, 2014
1 parent 3bb4656 commit b8ec93e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
a: color[3]
};
}
if (color.a !== 0) color.a = color.a || defs.defaults.DEF_COLOR_ALPHA;
var a = color.a;
if (a !== 0) a = a || defs.defaults.DEF_COLOR_ALPHA; // (don't modify the original color object)
if (color.r != parseInt(color.r) || color.r < 0 || color.r > 255 ||
color.g != parseInt(color.g) || color.g < 0 || color.g > 255 ||
color.b != parseInt(color.b) || color.b < 0 || color.b > 255 ||
color.a != parseInt(color.a) || color.a < 0 || color.a > 100)
a != parseInt(a) || a < 0 || a > 100)
return false;
}
return true;
Expand All @@ -42,6 +43,7 @@
a: color[3]
};
}
if (color.a !== 0) color.a = color.a || defs.defaults.DEF_COLOR_ALPHA;
return color;
}

Expand Down
11 changes: 11 additions & 0 deletions tests/02.operations/104.rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ describe('lwip.rotate', function() {
});
});

describe('-5 degs, {r:200,g:110,b:220} fill', function() {
it('should succeed', function(done) {
current.push(-5, 'degs', 'r-200,g-110,b-220');
image.rotate(-5, {
r: 200,
g: 110,
b: 220
}, done);
});
});

describe('-5 degs, {r:200,g:110,b:220,a:50} fill', function() {
it('should succeed', function(done) {
current.push(-5, 'degs', 'r-200,g-110,b-220,a-50');
Expand Down

0 comments on commit b8ec93e

Please sign in to comment.