Permalink
Browse files

Add support for a fillrect style that draws a filled rect instead of …

…just a rect
  • Loading branch information...
staktrace committed Feb 17, 2012
1 parent 0d06aa7 commit d82fbb5e09affa05d65fcb8ca53cd08c46a8d90d
Showing with 17 additions and 7 deletions.
  1. +17 −7 index.html
View
@@ -81,13 +81,14 @@
}
switch (tokens[j++]) {
+ case "fillrect":
case "rect":
if (j > tokens.length - 5) {
log("Error parsing line: " + lines[i]);
continue;
}
- var rect = {};
+ var rect = { type: tokens[j-1] };
renderData[destIndex].rects[tokens[j++]] = rect;
rect.x = parseFloat(tokens[j++]);
rect.y = parseFloat(tokens[j++]);
@@ -166,12 +167,21 @@
}
function drawRect(color, rect) {
- context.strokeStyle = color;
- context.strokeRect(
- projectX(rect.x),
- projectY(rect.y),
- rect.width * scale,
- rect.height * scale);
+ if (rect.type == 'rect') {
+ context.strokeStyle = color;
+ context.strokeRect(
+ projectX(rect.x),
+ projectY(rect.y),
+ rect.width * scale,
+ rect.height * scale);
+ } else if (rect.type == 'fillrect') {
+ context.fillStyle = color;
+ context.fillRect(
+ projectX(rect.x),
+ projectY(rect.y),
+ rect.width * scale,
+ rect.height * scale);
+ }
}
// vector is an object containg x,y properties. the vector

0 comments on commit d82fbb5

Please sign in to comment.