diff options
author | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-04-13 12:41:56 +0200 |
---|---|---|
committer | Ariya Hidayat <ariya.hidayat@nokia.com> | 2009-04-13 12:41:56 +0200 |
commit | 62e6c15f589ade08296739e2057831064a7615ea (patch) | |
tree | 9427522c3ff93e0778df6a281311755846016655 | |
parent | d1c73c0d21f752110e95dcb6275386acf1ac6172 (diff) |
Implement save() and restore() for our dummy Context2D.
This prevents the engine to trigger the exception.
Now the demo loops as it should.
-rw-r--r-- | qsmonster/magic.js | 18 | ||||
-rw-r--r-- | webmonster/magic.js | 18 |
2 files changed, 36 insertions, 0 deletions
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 = { |