-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcanvasext.js
38 lines (31 loc) · 929 Bytes
/
canvasext.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
define([
"dojo/_base/lang", "./_base", "./canvas"
], function (lang, gfx, canvas) {
/*=====
return {
// summary:
// A module that adds canvas-specific features to the gfx api. You should require this module
// when your application specifically targets the HTML5 Canvas renderer.
}
=====*/
var ext = gfx.canvasext = {};
lang.extend(canvas.Surface, {
getImageData: function (rect) {
// summary:
// Returns the canvas pixel buffer.
// rect: gfx.Rectangle
// The canvas area.
// flush pending renders queue, if any
if ("pendingRender" in this) {
this._render(true); // force render even if there're pendingImages
}
return this.rawNode.getContext("2d").getImageData(rect.x, rect.y, rect.width, rect.height);
},
getContext: function () {
// summary:
// Returns the surface CanvasRenderingContext2D.
return this.rawNode.getContext("2d");
}
});
return ext;
});