mightymandel v16

GPU-based Mandelbrot set explorer

zoom.c
Go to the documentation of this file.
1 // mightymandel -- GPU-based Mandelbrot Set explorer
2 // Copyright (C) 2012,2013,2014,2015 Claude Heiland-Allen
3 // License GPL3+ http://www.gnu.org/licenses/gpl.html
4 
5 #include "zoom.h"
6 
7 void zoom_begin(struct zoom *zoom, int frames, const mpfr_t centerx, const mpfr_t centery) {
8  mpfr_inits2(53, zoom->centerx, zoom->centery, zoom->radius, (mpfr_ptr) 0);
9  zoom->frame = -1;
10  zoom->zoom_frames = frames;
11  mpfr_set_prec(zoom->centerx, mpfr_get_prec(centerx));
12  mpfr_set_prec(zoom->centery, mpfr_get_prec(centery));
13  mpfr_set(zoom->centerx, centerx, MPFR_RNDN);
14  mpfr_set(zoom->centery, centery, MPFR_RNDN);
15  mpfr_set_si(zoom->radius, 256, MPFR_RNDN);
16 }
17 
18 void zoom_end(struct zoom *zoom) {
19  mpfr_clears(zoom->centerx, zoom->centery, zoom->radius, (mpfr_ptr) 0);
20 }
21 
22 bool zoom_next(struct zoom *zoom) {
23  zoom->frame++;
24  if (zoom->frame >= zoom->zoom_frames) {
25  return false;
26  }
27  mpfr_mul_2si(zoom->radius, zoom->radius, -1, MPFR_RNDN);
28  return true;
29 }