From 62e6c15f589ade08296739e2057831064a7615ea Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Mon, 13 Apr 2009 12:41:56 +0200 Subject: Implement save() and restore() for our dummy Context2D. This prevents the engine to trigger the exception. Now the demo loops as it should. --- qsmonster/magic.js | 18 ++++++++++++++++++ webmonster/magic.js | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/qsmonster/magic.js b/qsmonster/magic.js index 82b62b9..e50b379 100644 --- a/qsmonster/magic.js +++ b/qsmonster/magic.js @@ -47,7 +47,25 @@ var context = { 1.0, "none", this.fillStyle, this.pointCount, [x, y, x + w, y, x + w, y + h, x, y + h] ]; + }, + + state: [], + + save: function () { + this.state.push(this.globalAlpha); + this.state.push(this.strokeStyle); + this.state.push(this.fillStyle); + this.globalAlpha = 1.0; + this.strokeStyle = "rgba(0, 0, 0, 1)"; + this.fillStyle = "rgba(0, 0, 0, 1)"; + }, + + restore: function () { + this.fillStyle = this.state.pop(); + this.strokeStyle = this.state.pop(); + this.globalAlpha = this.state.pop(); } + }; var canvas = { diff --git a/webmonster/magic.js b/webmonster/magic.js index 056df11..7315db7 100644 --- a/webmonster/magic.js +++ b/webmonster/magic.js @@ -47,7 +47,25 @@ var context = { 1.0, "none", this.fillStyle, this.pointCount, [x, y, x + w, y, x + w, y + h, x, y + h] ]; + }, + + state: [], + + save: function () { + this.state.push(this.globalAlpha); + this.state.push(this.strokeStyle); + this.state.push(this.fillStyle); + this.globalAlpha = 1.0; + this.strokeStyle = "rgba(0, 0, 0, 1)"; + this.fillStyle = "rgba(0, 0, 0, 1)"; + }, + + restore: function () { + this.fillStyle = this.state.pop(); + this.strokeStyle = this.state.pop(); + this.globalAlpha = this.state.pop(); } + }; var canvas = { -- cgit v1.2.3