-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add interpolateColor worklet #960
Conversation
Unfortunately, I couldn't test these changes using modified react-native-reanimated package because I've got "Unsatisfied Link Error" for reanimated.so. I've tested using javascript playground. If there are maintainers with complete build setup - please, verify this pull-request is working. I think it should. |
Just a tiny note: you do not have to add |
I have these functions working well I think at https://github.com/wcandillon/react-native-redash/pull/289/files#diff-1234f550d692aff6b8f2a1952daf79ec. Is this helping? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please provide a piece of code with which you tested those changes? Thanks in advance
type = type || Extrapolate.CLAMP; | ||
|
||
const startColor = destructColor.apply({}, output[0]); | ||
const endColor = destructColor.appy({}, output[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, I guess expected word is apply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like with appy
misspell it doesn't work. If I would able to build react-native-reanimated npm package from master branch I'll fix misspell and add tests.
return undefined; | ||
} | ||
|
||
const r = interpolate.apply({}, x, input, [startColor[0], endColor[0]], type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't those args be wrapped in an array like const r = interpolate.apply({}, [x, input, [startColor[0], endColor[0]], type]);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and for the 3 following calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@likern, any update on this?
Interpolate color works well with redash worklets: https://github.com/wcandillon/react-native-redash/blob/master/src/Colors.ts#L201 feel free to copy this implementation if needed. |
Description
This PR adds
interpolateColor
worklet for Reanimated 2 which interpolates colors in RGBA space.For now there is no way to interpolate colors, only numbers are allowed.
Changes
destructColor
function which split number color into RGBA chanelsinterpolateColor
function which interpolates color