如何使用React Native Reanimated从interpolateColor获得RGB或HEX或RGBA值?



我想使用setState或类似的东西来存储和RGB值。InterpolateColor()目前返回一个大数字。这是我的回购:https://github.com/duether/react-native-color-picker

这个解决方案是用于将插值颜色转换为十六进制,我在这篇文章中找到了答案https://stackoverflow.com/a/697841/14332782所以我做了以下操作:

const decimalToHexString = (number: any) => {
if (number < 0) {
number = 0xffffffff + number + 1;
}
setColor(number.toString(16).substring(2, 8));
};

然后运行runOnJS(decimalToHexString)(interpolatedColor);

最新更新