Skip to content

Confusing type of ImageData.data #807

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

Closed
OndrejSpanel opened this issue Aug 23, 2023 · 3 comments · Fixed by #818
Closed

Confusing type of ImageData.data #807

OndrejSpanel opened this issue Aug 23, 2023 · 3 comments · Fixed by #818
Labels

Comments

@OndrejSpanel
Copy link

OndrejSpanel commented Aug 23, 2023

The ImageData.data is defined and documented as follows:

/** Is a Uint8ClampedArray representing a one-dimensional array containing the data in the RGBA order, with integer
* values between 0 and 255 (included).
*/
def data: js.Array[Int] = js.native

I am confused: is the type Uint8ClampedArray, or js.Array[Int]? Or are those types interchangeable somehow? If they are, perhaps the documentation could clarify how.

@armanbilge
Copy link
Member

Hmm. I don't think those are interchangeable. Seems like a bug to me.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray

@armanbilge armanbilge added the bug label Aug 23, 2023
@OndrejSpanel
Copy link
Author

I guess the interface of both JS types is similar enough, they both contain length and bracket access, therefore one can perform some basic operations on TypedArray thinking it is a normal array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants