Skip to content

Commit 915e13a

Browse files
committed
use unsigned value
1 parent d201da3 commit 915e13a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/color4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ color4.equals = function (a, b) {
289289
* @returns {Number}
290290
*/
291291
color4.hex = function (a) {
292-
return (a.r * 255) << 24 | (a.g * 255) << 16 | (a.b * 255) << 8 | a.a * 255;
292+
return ((a.r * 255) << 24 | (a.g * 255) << 16 | (a.b * 255) << 8 | a.a * 255) >>> 0;
293293
};
294294

295295
export default color4;

test/color4.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ tap.test('color4', t => {
322322

323323
t.equal(color4.hex(colorA), 0x7fff7fff);
324324

325+
color4.set(colorA, 1, 1, 1, 0);
326+
327+
t.equal(color4.hex(colorA), 0xffffff00);
328+
325329
t.end();
326330
});
327331

0 commit comments

Comments
 (0)