Skip to content

Commit

Permalink
fix(color): add proper rounding to rgbaInt()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 14, 2019
1 parent b44944a commit d956954
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/color/src/rgba-int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit d956954

Please sign in to comment.