canvas_query library
Functions
CqWrapper cq([selector, int height]) #
Create a CqWrapper object using a
selector. The
selector can be a
a String that should be used to query the DOM or an existing CanvasElement
or ImageElement that should be wrapped.
To create a new CqWrapper object with a specific size the
selector
argument will take an int argoument for the width.
If no argument is given, the size of the window will be used for the new
CanvasElement.
CqWrapper cq([var selector, int height]) {
var canvas;
if (null == selector || selector is int) {
int width = (selector != null ? selector : window.innerWidth);
height = (height != null ? height : window.innerHeight);
canvas = new CanvasElement(width: width, height: height);
} else if (selector is String) {
canvas = query(selector);
} else if (selector is ImageElement) {
canvas = CqTools.createCanvas(selector);
} else if (selector is CqWrapper) {
return selector;
} else {
canvas = selector;
}
return new CqWrapper(canvas);
}