Don't round calculation of rowHeight and columnWidth in the drawGrid function. If you want to plot points on the drawn grid, rounding these figures will lead to inaccuracies.

Signed-off-by: Dmitry Baranovskiy <dmitry.baranovskiy@gmail.com>
This commit is contained in:
Ben Askins 2008-12-22 12:50:03 +08:00 committed by Dmitry Baranovskiy
parent e41b27fb75
commit 9d3c93c06e
2 changed files with 6 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -1375,12 +1375,14 @@ var Raphael = (function (type) {
C.drawGrid = function (x, y, w, h, wv, hv, color) {
color = color || "#000";
var p = this.path({stroke: color, "stroke-width": 1})
.moveTo(x, y).lineTo(x + w, y).lineTo(x + w, y + h).lineTo(x, y + h).lineTo(x, y);
.moveTo(x, y).lineTo(x + w, y).lineTo(x + w, y + h).lineTo(x, y + h).lineTo(x, y),
rowHeight = h / hv,
columnWidth = w / wv;
for (var i = 1; i < hv; i++) {
p.moveTo(x, y + i * Math.round(h / hv)).lineTo(x + w, y + i * Math.round(h / hv));
p.moveTo(x, y + i * rowHeight).lineTo(x + w, y + i * rowHeight);
}
for (var i = 1; i < wv; i++) {
p.moveTo(x + i * Math.round(w / wv), y).lineTo(x + i * Math.round(w / wv), y + h);
p.moveTo(x + i * columnWidth, y).lineTo(x + i * columnWidth, y + h);
}
return p;
};