-
Notifications
You must be signed in to change notification settings - Fork 461
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
Handle SkColor creation from rgba tuple #2144
base: main
Are you sure you want to change the base?
Conversation
I've signed the cla. Bit weird it asks for an address. |
Thanks a lot I'm excited to sanitize the situation there. I added some tests for it at louix#1 but it seems to fail on Android. |
afa7967
to
f69e537
Compare
You were correct about 0-1 vs 0-255! The native side was just returning undefined if it wasn't sure how to handle the value, so you'd get an error where you tried to use the SkColor instead of when you created it. |
} | ||
return jsi::Value::undefined(); | ||
throw jsi::JSError(runtime, |
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.
yes that's fair
@louix please give me a bit of time to digest this. Recent work we've done may suggest we need to slightly change how colors are dealt with behind the scene. |
but either way the tests you've written will be very useful. |
Skia.Color
acceptsnumber[]
, but the native constructor doesn't actually account for it.In JsiSkColor::createCtor, if
argument[0].isObject()
(true for bothArray
andFloat32Array
), it's returned as is as the color value.When the
jsi::Value
is made into to anSkColor
in JsiSkColor::FromValue, the.buffer
property (which is of course is not there on an array -- thus undefined) is attempted to be accessed.I've added support here.
Orthogonally, have you considered using
[r: number, g: number, b: number, a: number]
instead ofnumber[]
for extra type saftey?Resolves #2113