Commit 9d3c93c0 by Ben Askins Committed by Dmitry Baranovskiy

Don't round calculation of rowHeight and columnWidth in the drawGrid function.…

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>
parent e41b27fb
......@@ -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;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment