From 51ff43734a015605de6e7a4f19fa2b37ab86db19 Mon Sep 17 00:00:00 2001 From: Fan Shi Date: Thu, 29 Dec 2011 21:28:11 +0800 Subject: [PATCH] Optimize visual effect --- AMPDemo/MandelbrotViewer/mandelbrot.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AMPDemo/MandelbrotViewer/mandelbrot.cpp b/AMPDemo/MandelbrotViewer/mandelbrot.cpp index c28e9c8..9379cec 100644 --- a/AMPDemo/MandelbrotViewer/mandelbrot.cpp +++ b/AMPDemo/MandelbrotViewer/mandelbrot.cpp @@ -89,10 +89,15 @@ void generate_mandelbrot( } while((length_sqr < _F(4.0)) && (count < max_iter)); - float h = sqrt(sin(count * 0.003067962f)); + float normalc = count / 512.0f; + float h = sqrt(1.0f - 1.0f / (normalc + 1.0f)); + + //float h = sqrt(fabs(sin(count * 0.003067962f)));; //float h = (float)count / 1024; //* 0.001953125f; //h = 1.8f * fabs(0.5f - h + floor(h)) + 0.1f; + + float bfactor = count >= max_iter ? 0.0f : 1.0f; - result[i] = set_hsb(h, 0.7f, (1.0f - h * h * 0.833333f)); + result[i] = set_hsb(h, 0.7f, (1.0f - h * h * 0.833333f) * bfactor); }); } \ No newline at end of file