From cc9c06da25900585243c0a6d4eae904006eefaa0 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 18 Dec 2017 15:21:23 +0100 Subject: [PATCH] P5-1987 add responsive guidelines --- dist/image-editor.js | 11 +++++++++-- src/GoreHandler.js | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/image-editor.js b/dist/image-editor.js index b01de18..a5d9932 100644 --- a/dist/image-editor.js +++ b/dist/image-editor.js @@ -1125,10 +1125,17 @@ function GoreHandler(viewport) { return this; } + var viewportData = viewport.getData(); var bounds = viewport.getBounds(); - var step = viewport.getData().ppmm * 450; - var count = Math.ceil(bounds.width / step); + var step = viewportData.ppmm * viewportData.image.scaleX * 450; + /* + * First round to 5 digits to fix pixel rounding issues when requested width is an even multiplier of 450mm. + * Could set precision higher but 5 decimals places should be enough, pixel rounding issues show somewhere + * around 15 decimals places. + * Then round up to get correct number of gores. + */ + var count = Math.ceil((bounds.width / step).toFixed(5)); for (var i = 1; i < count; i++) { _lines.push(getLine(bounds.left + step * i)); } diff --git a/src/GoreHandler.js b/src/GoreHandler.js index 3d6e996..b1163bc 100644 --- a/src/GoreHandler.js +++ b/src/GoreHandler.js @@ -43,10 +43,17 @@ function GoreHandler(viewport) { return this; } + var viewportData = viewport.getData(); var bounds = viewport.getBounds(); - var step = viewport.getData().ppmm * 450; - var count = Math.ceil(bounds.width / step); + var step = viewportData.ppmm * viewportData.image.scaleX * 450; + /* + * First round to 5 digits to fix pixel rounding issues when requested width is an even multiplier of 450mm. + * Could set precision higher but 5 decimals places should be enough, pixel rounding issues show somewhere + * around 15 decimals places. + * Then round up to get correct number of gores. + */ + var count = Math.ceil((bounds.width / step).toFixed(5)); for (var i = 1; i < count; i++) { _lines.push(getLine(bounds.left + step * i)); }