From 0a0f84ed93e56758dcbc13b7046ff9fba910560f Mon Sep 17 00:00:00 2001 From: David Tschumperle Date: Mon, 6 May 2024 08:24:23 +0200 Subject: [PATCH] Simplify 'draw_plasma()'. --- CImg.h | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/CImg.h b/CImg.h index 2ffd58d0..ab274eac 100644 --- a/CImg.h +++ b/CImg.h @@ -52459,37 +52459,29 @@ namespace cimg_library { // Square step. for (int y0 = 0; y0M?M:val); + const int x2 = x0 + delta2, y2 = y0 + delta2; + if (containsXYZC(x2,y2)) { + const int x1 = (x0 + delta)%w, y1 = (y0 + delta)%h; + const Tfloat val = (Tfloat)(0.25f*(ref(x0,y0) + ref(x1,y0) + ref(x1,y1) + ref(x0,y1)) + + r*cimg::rand(-1,1,&rng)); + ref(x2,y2) = (T)(valM?M:val); + } } // Diamond steps. - for (int y = -delta2; yM?M:val); - } - for (int y0 = 0; y0M?M:val); - } - for (int y = -delta2; yM?M:val); + bool is_odd_y = false; + for (int y0 = 0; y0M?M:val); + } } + is_odd_y = !is_odd_y; + } } } cimg::srand(rng);