flashlizi edited this page May 7, 2012 · 3 revisions


  • Introduction

HTML5 provides several approaches for graphics rendering, such as canvas, div+css3, VML, SVG etc. Normally, we use canvas and it's powerful. But it's lack performance on most of mobile devices. We found that div+css3 is an alternative in some cases. So we designed Context, like CanvasRenderingContext2D, a renderer.

  • Usage

At the moment, we have two kinds of context: CanvasContext and DOMContext.

A canvas context:

var canvas = document.getElementById("myCanvas"); //myCanvas is a canvas
var context = new Quark.CanvasContext({canvas:canvas});

A dom context:

var container = document.getElementById("container"); //container is a normal div
var context = new Quark.DOMContext({canvas:container}); //pass the container to DOMContext as a canvas.

After a context has instantiated and assigned to a stage, you don't need to care it normally.