Sciter v.2, immediate mode drawing

While porting Graphics functionality using Direct2D primitives I’ve tried to implement immediate mode drawing in Sciter.

Problem: as we know HTML5 mandates <canvas> to use off-screen bitmap buffer for drawings. Such model is not transform friendly (scale, rotation) as it involves bitmap transformation. So even when Graphics primitives (line,rectangle,etc.) are vector-ish the result is not a vector but a bitmap. With all consequences.


Now you can say something like this:

function myPaintFunction(graphics) { 
element.paintContent = myPaintFunction;

Last statement will assign your myPaintFunction to paintContent handler of the DOM element. And your myPaintFunction will be invoked when element will be drawn with graphics object already set for drawing. You can use separate paintContent, paintBackground and paintForeground handlers.

Immediate mode drawing also creates some new opportunities. Imagine that you need to write connector lines between two DOM elements at arbitrary locations. Now you can implement this using these immediate paint feature.