summaryrefslogtreecommitdiff
path: root/apps/plugins/fractals/mandelbrot_set.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/fractals/mandelbrot_set.c')
-rw-r--r--apps/plugins/fractals/mandelbrot_set.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/apps/plugins/fractals/mandelbrot_set.c b/apps/plugins/fractals/mandelbrot_set.c
index fdd741d658..53ac7f275d 100644
--- a/apps/plugins/fractals/mandelbrot_set.c
+++ b/apps/plugins/fractals/mandelbrot_set.c
@@ -30,19 +30,25 @@ static unsigned char imgbuffer[LCD_HEIGHT];
30static fb_data imgbuffer[LCD_HEIGHT]; 30static fb_data imgbuffer[LCD_HEIGHT];
31#endif 31#endif
32 32
33/* 8 entries cyclical, last entry is black (convergence) */ 33#define NUM_COLORS 8 /* Must be a power of 2 */
34/* NUM_COLORS entries cyclical, last entry is black (convergence) */
34#ifdef HAVE_LCD_COLOR 35#ifdef HAVE_LCD_COLOR
35static const fb_data color[9] = { 36static const fb_data color[NUM_COLORS] = {
36 LCD_RGBPACK(255, 0, 159), LCD_RGBPACK(159, 0, 255), LCD_RGBPACK(0, 0, 255), 37 LCD_RGBPACK(255, 0, 159), LCD_RGBPACK(159, 0, 255),
37 LCD_RGBPACK(0, 159, 255), LCD_RGBPACK(0, 255, 128), LCD_RGBPACK(128, 255, 0), 38 LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(0, 159, 255),
38 LCD_RGBPACK(255, 191, 0), LCD_RGBPACK(255, 0, 0), LCD_RGBPACK(0, 0, 0) 39 LCD_RGBPACK(0, 255, 128), LCD_RGBPACK(128, 255, 0),
40 LCD_RGBPACK(255, 191, 0), LCD_RGBPACK(255, 0, 0)
39}; 41};
42#define CONVERGENCE_COLOR LCD_RGBPACK(0, 0, 0)
40#else /* greyscale */ 43#else /* greyscale */
41static const unsigned char color[9] = { 44static const unsigned char color[NUM_COLORS] = {
42 255, 223, 191, 159, 128, 96, 64, 32, 0 45 255, 223, 191, 159, 128, 96, 64, 32
43}; 46};
47#define CONVERGENCE_COLOR 0
44#endif 48#endif
45 49
50#define COLOR(iter) color[(iter) % (NUM_COLORS - 1)]
51
46#if CONFIG_LCD == LCD_SSD1815 52#if CONFIG_LCD == LCD_SSD1815
47/* Recorder, Ondio: pixel_height == 1.25 * pixel_width */ 53/* Recorder, Ondio: pixel_height == 1.25 * pixel_width */
48#define MB_HEIGHT (LCD_HEIGHT*5/4) 54#define MB_HEIGHT (LCD_HEIGHT*5/4)
@@ -196,9 +202,9 @@ static int mandelbrot_calc_low_prec(struct fractal_rect *rect,
196 } 202 }
197 203
198 if (n_iter > ctx.max_iter) 204 if (n_iter > ctx.max_iter)
199 imgbuffer[p_y] = color[8]; 205 imgbuffer[p_y] = CONVERGENCE_COLOR;
200 else 206 else
201 imgbuffer[p_y] = color[n_iter & 7]; 207 imgbuffer[p_y] = COLOR(n_iter);
202 208
203 /* be nice to other threads: 209 /* be nice to other threads:
204 * if at least one tick has passed, yield */ 210 * if at least one tick has passed, yield */
@@ -293,9 +299,9 @@ static int mandelbrot_calc_high_prec(struct fractal_rect *rect,
293 } 299 }
294 300
295 if (n_iter > ctx.max_iter) 301 if (n_iter > ctx.max_iter)
296 imgbuffer[p_y] = color[8]; 302 imgbuffer[p_y] = CONVERGENCE_COLOR;
297 else 303 else
298 imgbuffer[p_y] = color[n_iter & 7]; 304 imgbuffer[p_y] = COLOR(n_iter);
299 305
300 /* be nice to other threads: 306 /* be nice to other threads:
301 * if at least one tick has passed, yield */ 307 * if at least one tick has passed, yield */