2

I am representing an image as:

data Image = Image { size :: V2 Int, buffer :: UVector.Vector Word32 }

That is, a row-major unboxed array of RGBA Word32 pixels. That format is the same used by JavaScript's Canvas's ImageData. You could blit such a vector into a JS's canvas with something like:

function blit(canvas, img){
    var ctx = canvas.getContext("2d");
    ctx.putImageData(new ImageData(img.buffer, img.size.x, img.size.y), 0, 0);
};

What I want is to have a widget on Haskell that calls this "blit" function on the cames every other frame using a Dynamic Image. How is that possible?

MaiaVictor
  • 51,090
  • 44
  • 144
  • 286

0 Answers0