P5-2008 fix inches on gores

This commit is contained in:
Anders Gustafsson
2018-01-03 15:17:14 +01:00
parent 90d6a3d2bb
commit c2ef3fce55
3 changed files with 14 additions and 2 deletions
+7 -1
View File
@@ -1136,6 +1136,7 @@ function GoreHandler(viewport) {
* 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));
}
@@ -2237,6 +2238,7 @@ module.exports = assertKeyValuePair;
function calcCrop(obj, width, height, units) {
var cropRatio = width / height;
var objRatio = obj.width / obj.height;
var inchToCm = units === "inch" ? 2.54 : 1;
var returnValue = {
image: obj,
@@ -2259,7 +2261,11 @@ function calcCrop(obj, width, height, units) {
}
// Pixels per millimeter
returnValue.ppmm = returnValue.width / ((returnValue.dim.width * obj.scaleX) * 10);
var ppmm = returnValue.width / ((returnValue.dim.width * inchToCm * obj.scaleX) * 10);
//Round to four decimal places to avoid precision issues. At least 4 decimals is needed though
//for correct calculation of number of gores on wide wallpaperes in editor.
returnValue.ppmm = Math.round(ppmm * 1e4) / 1e4;
return returnValue;
}
+1
View File
@@ -54,6 +54,7 @@ function GoreHandler(viewport) {
* 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));
}
+6 -1
View File
@@ -15,6 +15,7 @@
function calcCrop(obj, width, height, units) {
var cropRatio = width / height;
var objRatio = obj.width / obj.height;
var inchToCm = units === "inch" ? 2.54 : 1;
var returnValue = {
image: obj,
@@ -37,7 +38,11 @@ function calcCrop(obj, width, height, units) {
}
// Pixels per millimeter
returnValue.ppmm = returnValue.width / ((returnValue.dim.width * obj.scaleX) * 10);
var ppmm = returnValue.width / ((returnValue.dim.width * inchToCm * obj.scaleX) * 10);
//Round to four decimal places to avoid precision issues. At least 4 decimals is needed though
//for correct calculation of number of gores on wide wallpaperes in editor.
returnValue.ppmm = Math.round(ppmm * 1e4) / 1e4;
return returnValue;
}