Closed jlrickert closed 2 years ago
This could also be implemented with poly variants:
For example:
@send
external draw: (
t,
@unwrap [#Image(Webapi__Dom__HtmlImageElement.t) | #Canvas(Webapi__Dom__HtmlCanvasElement.t)],
~dx: float,
~dy: float,
) => unit = "drawImage"
let _: unit = ctx->draw(#Image(image), ~dx=0.0, ~dy=0.0)
Output:
ctx.drawImage(image, 0.0, 0.0);
This could also be implemented with poly variants:
I keep forgetting about that unwrap unary polymorphic variant constructors feature. That would be a really good fit for this case.
I suspect @spocke forgot to update his request for changes so I'm just going to admin merge this.
Released as 0.5.0
Relates to issue #62
Things added
Example usage
Things to do
CanvasImageSource could also be applied to a bunch of other modules. However, they don't seem to exist yet.