Skip to content

Commit b68266b

Browse files
committed
Fix
1 parent 96ff0cc commit b68266b

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Next
22

3+
- Fix an issue with normalizing RGB(A) values
4+
35
## v0.16.2
46

57
- Stop calling `camera.refresh()` as that is unnecessary since `v1.2.2`

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export const toRgba = (color, isNormalize) => {
302302
if (isRgba(color)) {
303303
const base = 255 ** !isNormalize;
304304
return isNormalize && !isNormFloatArray(color)
305-
? normNumArray(color)
305+
? color.map((x) => x / 255)
306306
: normNumArray(color).map((x) => x * base);
307307
}
308308

tests/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,8 +1742,8 @@ test('toRgba()', async (t) => {
17421742
);
17431743

17441744
t.equal(
1745-
toRgba([255, 0, 0, 153], true),
1746-
[1, 0, 0, 0.6],
1745+
toRgba([153, 0, 0, 153], true),
1746+
[0.6, 0, 0, 0.6],
17471747
'should convert RGBA to normalized RGBA'
17481748
);
17491749

0 commit comments

Comments
 (0)