Skip to content

Commit 2c7d52b

Browse files
committed
chore: clean up utils
1 parent 409b43a commit 2c7d52b

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

src/utils.ts

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,19 @@ function parseColor(color: string): RiveRGBA {
4646
return { r: 0, g: 0, b: 0, a: 255 };
4747
}
4848

49-
let r = 0,
50-
g = 0,
51-
b = 0,
49+
let r = parseInt(hex.slice(0, 2), 16),
50+
g = parseInt(hex.slice(2, 4), 16),
51+
b = parseInt(hex.slice(4, 6), 16),
5252
a = 255;
5353

54-
if (hex.length === 6) {
55-
// Format: RRGGBB
56-
r = parseInt(hex.slice(0, 2), 16);
57-
g = parseInt(hex.slice(2, 4), 16);
58-
b = parseInt(hex.slice(4, 6), 16);
59-
} else if (hex.length === 8) {
60-
// Format: RRGGBBAA
61-
r = parseInt(hex.slice(0, 2), 16);
62-
g = parseInt(hex.slice(2, 4), 16);
63-
b = parseInt(hex.slice(4, 6), 16);
54+
// Optionally parse alpha channel if present
55+
if (hex.length === 8) {
6456
a = parseInt(hex.slice(6, 8), 16);
65-
} else {
66-
console.warn(`Rive invalid hex color: ${color}`);
6757
}
6858

6959
return { r, g, b, a };
7060
}
7161
export { parsePossibleSources, parseColor };
7262

73-
export const getPropertyTypeString = (propertyType: PropertyType): string => {
74-
return propertyType; // Since PropertyType values are strings
75-
};
63+
export const getPropertyTypeString = (propertyType: PropertyType): string =>
64+
propertyType;

0 commit comments

Comments
 (0)