From f12e66cf37d9a3dea0ee2e263dc4a17d65083412 Mon Sep 17 00:00:00 2001 From: ahmadileham <96009848+ahmadileham@users.noreply.github.com> Date: Tue, 7 Jan 2025 20:13:10 +0800 Subject: [PATCH] fix gravity width --- main/background.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/main/background.js b/main/background.js index cc71be9..073b9fb 100755 --- a/main/background.js +++ b/main/background.js @@ -1069,7 +1069,7 @@ function placeParts(sheets, parts, config, nestindex){ // weigh width more, to help compress in direction of gravity if(config.placementType == 'gravity'){ - area = rectbounds.width*2 + rectbounds.height; + area = rectbounds.width*5 + rectbounds.height; } else{ area = rectbounds.width * rectbounds.height; @@ -1110,19 +1110,18 @@ function placeParts(sheets, parts, config, nestindex){ if( minarea === null || - area < minarea || - (GeometryUtil.almostEqual(minarea, area) && (minx === null || shiftvector.x < minx)) || - (GeometryUtil.almostEqual(minarea, area) && (minx !== null && GeometryUtil.almostEqual(shiftvector.x, minx) && shiftvector.y < miny)) + (config.placementType == 'gravity' && ( + rectbounds.width < minwidth || + (GeometryUtil.almostEqual(rectbounds.width, minwidth) && area < minarea) + )) || + (config.placementType != 'gravity' && area < minarea) || + (GeometryUtil.almostEqual(minarea, area) && shiftvector.x < minx) ){ minarea = area; - minwidth = rectbounds ? rectbounds.width : 0; + minwidth = rectbounds.width; position = shiftvector; - if(minx === null || shiftvector.x < minx){ - minx = shiftvector.x; - } - if(miny === null || shiftvector.y < miny){ - miny = shiftvector.y; - } + minx = shiftvector.x; + miny = shiftvector.y; if(config.mergeLines){ position.mergedLength = merged.totalLength;