From 7abb323e7d65052ebc30fd7f6fd69ca34eb1fc5b Mon Sep 17 00:00:00 2001 From: patrickas Date: Sat, 21 Jan 2023 22:04:00 +0200 Subject: [PATCH 1/4] Only call recalculateBg when things actually change --- js/lib/layers.js | 1 + js/ui/tool/dream.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/js/lib/layers.js b/js/lib/layers.js index 96ea9c0..2d4d40b 100644 --- a/js/lib/layers.js +++ b/js/lib/layers.js @@ -384,6 +384,7 @@ const layers = { if (JSON.stringify(expand_by) !== JSON.stringify([0, 0, 0, 0])) { this.expand(...expand_by); + recalculateBg(); } }, diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index c06c1ef..2e409f5 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -1516,7 +1516,6 @@ const dreamTool = () => if (global.connection === "online") { imageCollection.auto_expand_to_fit(bb); - recalculateBg(); dream_generate_callback(bb, resolution, state); } else { const stop = march(bb, { From a161b3692f0ac62ebf1f697a55714d3c87a4078c Mon Sep 17 00:00:00 2001 From: patrickas Date: Sat, 21 Jan 2023 22:06:08 +0200 Subject: [PATCH 2/4] Selecting outside the canvas expands it --- js/ui/tool/select.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/ui/tool/select.js b/js/ui/tool/select.js index 6a1095b..4b95abd 100644 --- a/js/ui/tool/select.js +++ b/js/ui/tool/select.js @@ -424,6 +424,7 @@ const selectTransformTool = () => selection.dragendcb(evn); const bb = selection.bb; + imageCollection.auto_expand_to_fit(bb); state.reset(); From 9dd27ac0e82ed3d3b57f17670a77dad7c14a8636 Mon Sep 17 00:00:00 2001 From: patrickas Date: Sat, 21 Jan 2023 23:08:52 +0200 Subject: [PATCH 3/4] When stamp tool is selected and we have an image selected, moving the cursor outside the boundary expands it --- js/ui/tool/stamp.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/ui/tool/stamp.js b/js/ui/tool/stamp.js index 2ac60bd..4a6ff34 100644 --- a/js/ui/tool/stamp.js +++ b/js/ui/tool/stamp.js @@ -396,6 +396,8 @@ const stampTool = () => // Draw selected image if (state.selected) { + const bb = getBoundingBox(sx,sy,1,1,false) + imageCollection.auto_expand_to_fit(bb); ovCtx.save(); ovCtx.translate(px, py); ovCtx.scale(state.scale, state.scale); From cc536479bbaaa54575d4b5c2732c54670fd96b2e Mon Sep 17 00:00:00 2001 From: patrickas Date: Sun, 22 Jan 2023 19:08:22 +0200 Subject: [PATCH 4/4] We expand when stamping not when moving the cursor. The current area we are expanding to is currently wrong though --- js/ui/tool/stamp.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/ui/tool/stamp.js b/js/ui/tool/stamp.js index 4a6ff34..fa64568 100644 --- a/js/ui/tool/stamp.js +++ b/js/ui/tool/stamp.js @@ -396,8 +396,6 @@ const stampTool = () => // Draw selected image if (state.selected) { - const bb = getBoundingBox(sx,sy,1,1,false) - imageCollection.auto_expand_to_fit(bb); ovCtx.save(); ovCtx.translate(px, py); ovCtx.scale(state.scale, state.scale); @@ -421,6 +419,10 @@ const stampTool = () => const resource = state.selected; if (resource) { + const real_bb = getBoundingBox(sx,sy,1,1); //TODO:Here we have to get the actual real bounding box somehow + imageCollection.auto_expand_to_fit(real_bb); + state.redraw(); + const {canvas, bb} = cropCanvas(ovCanvas, {border: 10}); commands.runCommand("drawImage", "Image Stamp", { image: canvas,