From 2f8e8d507f40164c777337a3fdb37433fe315bb5 Mon Sep 17 00:00:00 2001 From: Dan Royer Date: Thu, 19 Oct 2023 13:14:42 -0700 Subject: [PATCH] slightly less memory smashing --- .../Converter_QuadTreeInstant.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/marginallyclever/makelangelo/makeart/imageconverter/Converter_QuadTreeInstant.java b/src/main/java/com/marginallyclever/makelangelo/makeart/imageconverter/Converter_QuadTreeInstant.java index 53ccfd576..1d37cc0c4 100644 --- a/src/main/java/com/marginallyclever/makelangelo/makeart/imageconverter/Converter_QuadTreeInstant.java +++ b/src/main/java/com/marginallyclever/makelangelo/makeart/imageconverter/Converter_QuadTreeInstant.java @@ -99,7 +99,7 @@ public void start(Paper paper, TransformedImage image){ turtle = new Turtle(); BoxCondition boxCondition = new BoxCondition(true,true,true,true); - fractal(topLeftP, bottomRightP, boxCondition, 0,baseCutOff); + recurse(topLeftP, bottomRightP, boxCondition, 0,baseCutOff); fireConversionFinished(); } @@ -116,7 +116,7 @@ private float getAverageOfRegion(Point2D topLeft, Point2D bottomRight) { return sum/c; } - private void fractal(Point2D topLeft, Point2D bottomRight, BoxCondition boxCondition, int curDepth, int cutOff){ + private void recurse(Point2D topLeft, Point2D bottomRight, BoxCondition boxCondition, int curDepth, int cutOff){ if(curDepth > maxDepth) return; float average = getAverageOfRegion(topLeft, bottomRight); @@ -125,20 +125,20 @@ private void fractal(Point2D topLeft, Point2D bottomRight, BoxCondition boxCondi // only draw the sides of the box that are needed if(boxCondition.drawTop) { - drawLine(new Point2D(topLeft.x, topLeft.y), + drawLine(topLeft, new Point2D(bottomRight.x, topLeft.y)); } if(boxCondition.drawBottom) { drawLine(new Point2D(topLeft.x, bottomRight.y), - new Point2D(bottomRight.x, bottomRight.y)); + bottomRight); } if(boxCondition.drawLeft) { - drawLine(new Point2D(topLeft.x, topLeft.y), + drawLine(topLeft, new Point2D(topLeft.x, bottomRight.y)); } if(boxCondition.drawRight) { drawLine(new Point2D(bottomRight.x, topLeft.y), - new Point2D(bottomRight.x, bottomRight.y)); + bottomRight); } // go deeper, but each time lower the cutoff. darker regions will start to fail the test. @@ -147,26 +147,26 @@ private void fractal(Point2D topLeft, Point2D bottomRight, BoxCondition boxCondi int w2 = (int)(bottomRight.x - topLeft.x)/2; int h2 = (int)(topLeft.y - bottomRight.y)/2; // top left corner - fractal(new Point2D(topLeft.x, topLeft.y), + recurse(topLeft, new Point2D(topLeft.x + w2, topLeft.y-h2), new BoxCondition(false,true,false,true), curDepth+1, newCutOff); // top right corner - fractal(new Point2D(topLeft.x + w2, topLeft.y), + recurse(new Point2D(topLeft.x + w2, topLeft.y), new Point2D(bottomRight.x, topLeft.y-h2), new BoxCondition(false,true,true,false), curDepth+1, newCutOff); // bottom left corner - fractal(new Point2D(topLeft.x, topLeft.y-h2), + recurse(new Point2D(topLeft.x, topLeft.y-h2), new Point2D(topLeft.x+w2, bottomRight.y), new BoxCondition(true,false,false,true), curDepth+1, newCutOff); // bottom right corner - fractal(new Point2D(topLeft.x+w2, topLeft.y-h2), - new Point2D(bottomRight.x, bottomRight.y), + recurse(new Point2D(topLeft.x+w2, topLeft.y-h2), + bottomRight, new BoxCondition(true,false,true,false), curDepth+1, newCutOff);