summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qsmonster/magic.js18
-rw-r--r--webmonster/magic.js18
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 = {