Closed dragonfly-ai closed 6 months ago
Should we introduce an ImageSettings class?
The JS docs just supply them with anonymous arguments:
let imageData = new ImageData(200, 100, { colorSpace: "display-p3" });
Should we introduce an ImageSettings class?
Yes. Here's an example of how it should be defined.
OK, I'll try to add that, too.
What about adding a companion object to ImageSettings
since its only field supports exactly two values: "srgb" and "display-p3"?
I mean to store static values for the two types of ImageSettings
instances needed to encode the two supported color models.
What about adding a companion object to ImageSettings since its only field supports exactly two values: "srgb" and "display-p3"?
Wouldn't these be better off as an enum
then? E.g. ImageSettingsColorSpace
?
@dragonfly-ai This PR LGTM, if you want to add the enum or not, let me know, it can always be a separate ticket/PR
Thanks for approving! I've never tried passing a Scala enum to a native JS function; do Scala enumerations interoperate well with plain JavaScript?
No, they don't.
Well, in that case, companion object with constants for display-p3
and srgb
, or should we just leave it out?
Added the ImageSettings
object as discussed.
The ImageData spec references several constructors that scala-js-dom has omitted:
https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData
This PR means to include these features.