Permalink
Browse files

Fix bench stroke/filling a previous path regression

  • Loading branch information...
1 parent 93cbcc0 commit f3a7a6b0401907d627aac84a3dda1b04f691e4fc @chellmuth committed Jan 9, 2014
Showing with 10 additions and 0 deletions.
  1. +3 −0 lib/bench.dart
  2. +6 −0 lib/view.dart
  3. +1 −0 web/hive.dart
View
@@ -17,6 +17,7 @@ class Bench {
var left = canvas.width * (1 - widthRatio) / 2;
var top = canvas.height - height;
var width = canvas.width * widthRatio;
+ context.beginPath();
context.rect(left, top, width, height + 1);
context.fill();
context.stroke();
@@ -36,5 +37,7 @@ class Bench {
var textWidth = metrics.width;
context.fillText(player2, left + width * 3 / 4 - textWidth / 2, top + fontSize + verticalMargin);
}
+
+ context.restore();
}
}
View
@@ -34,6 +34,7 @@ abstract class HexView {
}
void draw(CanvasRenderingContext2D context) {
+ context.save();
context.fillStyle = fillColor;
context.strokeStyle = strokeColor;
context.beginPath();
@@ -46,6 +47,7 @@ abstract class HexView {
context.closePath();
context.fill();
context.stroke();
+ context.restore();
}
}
@@ -77,6 +79,8 @@ class TileView extends HexView {
void draw(CanvasRenderingContext2D context) {
//super.draw(context);
+ context.save();
+
var xStackOffset = 6, yStackOffset = 10;
var xOffset = this.xOffset + (tile.height - 1) * xStackOffset;
var yOffset = this.yOffset - (tile.height - 1) * yStackOffset;
@@ -105,6 +109,8 @@ class TileView extends HexView {
coveredPieceView.draw(context, coveredPieceBounds);
coveredPieceBounds = new Rectangle(coveredPieceBounds.left, coveredPieceBounds.top - diameter - margin, coveredPieceBounds.width, coveredPieceBounds.height);
}
+
+ context.restore();
}
void _renderOneDot(CanvasRenderingContext2D context, Rectangle boundingRect) {
View
@@ -206,5 +206,6 @@ void render(GameState gamestate, { List<Move> moves : null }) {
}
context.restore();
+
bench.draw(context, canvas);
}

0 comments on commit f3a7a6b

Please sign in to comment.