|
|
|
@ -61,6 +61,20 @@ function GradientProxy(stack, x0, y0, x1, y1) {
@@ -61,6 +61,20 @@ function GradientProxy(stack, x0, y0, x1, y1) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var patternProxyCounter = 0; |
|
|
|
|
function PatternProxy(stack, object, kind) { |
|
|
|
|
this.id = patternProxyCounter++; |
|
|
|
|
|
|
|
|
|
if (!(object instanceof CanvasProxy) ) { |
|
|
|
|
throw "unkown type to createPattern"; |
|
|
|
|
} |
|
|
|
|
// Flush the object here to ensure it's available on the main thread.
|
|
|
|
|
// TODO: Make some kind of dependency management, such that the object
|
|
|
|
|
// gets flushed only if needed.
|
|
|
|
|
object.flush(); |
|
|
|
|
stack.push(["$createPatternFromCanvas", [this.id, object.id, kind]]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var canvasProxyCounter = 0; |
|
|
|
|
function CanvasProxy(width, height) { |
|
|
|
|
this.id = canvasProxyCounter++; |
|
|
|
@ -76,10 +90,6 @@ function CanvasProxy(width, height) {
@@ -76,10 +90,6 @@ function CanvasProxy(width, height) {
|
|
|
|
|
return ctx; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.getCanvas = function() { |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Expose only the minimum of the canvas object - there is no dom to do
|
|
|
|
|
// more here.
|
|
|
|
|
this.width = width; |
|
|
|
@ -105,7 +115,7 @@ function CanvasProxy(width, height) {
@@ -105,7 +115,7 @@ function CanvasProxy(width, height) {
|
|
|
|
|
"transform", |
|
|
|
|
"setTransform", |
|
|
|
|
// "createLinearGradient",
|
|
|
|
|
"createPattern", |
|
|
|
|
// "createPattern",
|
|
|
|
|
"clearRect", |
|
|
|
|
"fillRect", |
|
|
|
|
"strokeRect", |
|
|
|
@ -129,6 +139,10 @@ function CanvasProxy(width, height) {
@@ -129,6 +139,10 @@ function CanvasProxy(width, height) {
|
|
|
|
|
"$showText" |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
ctx.createPattern = function(object, kind) { |
|
|
|
|
return new PatternProxy(stack, object, kind); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ctx.createLinearGradient = function(x0, y0, x1, y1) { |
|
|
|
|
return new GradientProxy(stack, x0, y0, x1, y1); |
|
|
|
|
} |
|
|
|
@ -219,6 +233,8 @@ function CanvasProxy(width, height) {
@@ -219,6 +233,8 @@ function CanvasProxy(width, height) {
|
|
|
|
|
return function(value) { |
|
|
|
|
if (value instanceof GradientProxy) { |
|
|
|
|
stack.push(["$" + name + "Gradient"]); |
|
|
|
|
} else if (value instanceof PatternProxy) { |
|
|
|
|
stack.push(["$" + name + "Pattern", [value.id]]); |
|
|
|
|
} else { |
|
|
|
|
stack.push(["$", name, value]); |
|
|
|
|
return ctx["$" + name] = value; |
|
|
|
|