From d956954a12423ad4df0b94ebb2a54d94ea121f96 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Wed, 14 Aug 2019 02:30:26 +0100 Subject: [PATCH] fix(color): add proper rounding to rgbaInt() --- packages/color/src/rgba-int.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/color/src/rgba-int.ts b/packages/color/src/rgba-int.ts index e4a4387a22..a559ca739f 100644 --- a/packages/color/src/rgba-int.ts +++ b/packages/color/src/rgba-int.ts @@ -3,8 +3,8 @@ import { ReadonlyColor } from "./api"; import { ensureAlpha } from "./internal/ensure-alpha"; export const rgbaInt = (src: ReadonlyColor) => - (((ensureAlpha(src[3]) * 0xff) << 24) | - ((clamp01(src[0]) * 0xff) << 16) | - ((clamp01(src[1]) * 0xff) << 8) | - (clamp01(src[2]) * 0xff)) >>> + (((ensureAlpha(src[3]) * 0xff + 0.5) << 24) | + ((clamp01(src[0]) * 0xff + 0.5) << 16) | + ((clamp01(src[1]) * 0xff + 0.5) << 8) | + (clamp01(src[2]) * 0xff + 0.5)) >>> 0;