← Back to team overview

duetto-beta-testers team mailing list archive

Re: Some canvas-related questions

 

Hi Valentine,


1) You're right, canvas.h is a legacy header and should have not be included 
in the package. Please use the definition in clientlib.h

2) I believe you are referring to createImageData. It's definitely possible to 
use regular inheritance. The headers have been generated from TypeScript 
library declarations. They were useful to quickly have a decently typed 
interface to browser APIs, but they are not perfect because TypeScript does 
not support overloading. The resulting clientlib.h header in duetto will 
require some manual tuning to be better adapted to C++.

3) My favorite one would be asynchrously loading images by creating an img tag 
using

document.createElement("img")

then you can use event handling to know when images are ready and blit them 
using drawImage

Regards,
Alessandro

> Hello,
> 
> I enjoy being one of first 100 Duetto beta testers. Thanks for this
> opportunity!
> 
> 
> After reading header files in include/duetto, some question regarding canvas
> have arisen:
> 
> 
> 1. HTMLCanvasElement and CanvasRenderingContext2D are defined both in
> canvas.h and clientlib.h - what's the reason for that? Looks like
> definitions in clientlib.h are far more complete. Should I use them and not
> those in canvas.h?
> 
> 
> 2. CanvasRenderingContext2D::getImageData() always expects Object * as its
> first argument. Given the name imageDataOrSw I suppose it's a way to
> overload the method according to spec [1]: getImageData(double, double) and
> getImageData(ImageData). How is it supposed to be called if I want
> ImageData of given width and height? What are the reasons for not
> overloading it in a 'straight' way:
> 
> ImageData * CanvasRenderingContext2D::getImageData(double, double)
> ImageData * CanvasRenderingContext2D::getImageData(Imagedata *)?
> 
> 3. What is the most idiomatic way to draw an existing PNG file on a canvas?
> I've come up with different solutions, including using
> createImageData()/putImageData() and [[server]] method returning bitmap
> array; using drawImage() and [[server]] method returning image as data:
> url; using drawImage() and HTTP backend to serve static for
> HTMLImageElement. Which one should be preferred?
> 
> 
> Thank you very much for the clarifications!
> --
> Sincerely,
> Valentine Sinitsyn


Follow ups