示例#1
0
int main(int argc, char const *argv[])
{
	int n = argc < 2 ? 2 : atoi(argv[1]);
	omp_set_num_threads(n);
	omp_set_dynamic(0);
	printf("set number of threads to %d\n",n);
	printf("disabled dynamic\n");
	double pmin = -2.25, pmax = 0.75, qmin = -1.5, qmax = 1.5;
	double maxv = 100;
	int maxk = 256;
	int w = 640;
	int h = 480;
	double tp = omp_get_wtime();
	std::vector<unsigned char> image(w*h);
	std::vector<unsigned char> image2(w*h);
	#pragma omp parallel
	{
		#pragma omp single
		{
			printf("warmup\n");
		}
	}
	printf("all grid testing using runtime (OMP_SCHEDULE) environment variable\n");
	double t0 = omp_get_wtime();
	#pragma omp parallel for shared(image) firstprivate(h,w) collapse(2) schedule(runtime)
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
		{
			int k = mandel(i*((pmax-pmin)/h)+pmin,j*((qmax-qmin)/w)+qmin, maxv, maxk);
			image[i*w+j] = k >= maxk ? 0 : k;
			image2[i*w+j] = omp_get_thread_num()*256/n;
		}

	stbi_write_png("outgrid_result.png",w,h,1,&image[0],w);
	stbi_write_png("outgrid_assign.png",w,h,1,&image2[0],w);
	double t1 = omp_get_wtime();
	printf("Output is %f and warmup %f\n",t1-t0,t0-tp);

	printf("only row testing using runtime (OMP_SCHEDULE) environment variable\n");
	{
	double t0 = omp_get_wtime();
	W ww(10);
	// NOTE: cannot use nor private or firstprivate for ww
	#pragma omp parallel for shared(image) firstprivate(h,w) schedule(runtime) shared(ww)
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
		{
			int k = mandel(i*((pmax-pmin)/h)+pmin,j*((qmax-qmin)/w)+qmin, maxv, maxk);
			image[i*w+j] = k >= maxk ? 0 : k;
			image2[i*w+j] = omp_get_thread_num()*256/n;
		}

	stbi_write_png("outrows_result.png",w,h,1,&image[0],w);
	stbi_write_png("outrows_assign.png",w,h,1,&image2[0],w);
	double t1 = omp_get_wtime();
	printf("Output is %f and warmup %f\n",t1-t0,t0-tp);
	}
	return 0;
}
示例#2
0
void		mandelbrot(t_env *en)
{
	int		i;
	double	tmp;

	en->x = 0;
	while (en->x++ < en->image_x)
	{
		en->y = 0;
		while (en->y++ < en->image_y)
		{
			i = mandel(en);
			while (i++ < en->iter && en->zr * en->zr + en->zi * en->zi < 4)
			{
				tmp = en->zr;
				en->zr = (en->zr * en->zr) - (en->zi * en->zi) + en->cr;
				en->zi = 2 * en->zi * tmp + en->ci;
			}
			if (i == en->iter)
				output(en, 1, 6, 9);
			else
				output(en, i * 200 / en->iter - en->blue - 200, i * 200 /
					en->iter - en->green - 200, i * 200 / en->iter
					- en->red - 200);
		}
	}
}
void MandelTiled(NaClSrpcRpc *rpc,
                 NaClSrpcArg **in_args,
                 NaClSrpcArg **out_args,
                 NaClSrpcClosure *done) {
  double xlow = in_args[0]->u.dval;
  double ylow = in_args[1]->u.dval;
  double points_per_tile = in_args[2]->u.dval;
  double tiles_per_row = in_args[3]->u.dval;
  char* p;
  double x;
  double y;

  /*
   * Compute square tiles of the mandelbrot set, leaving the result in
   * the shared memory region.
   */
  p = shm_addr;
  for (x = xlow; x < xlow + points_per_tile; ++x) {
    for (y = ylow; y < ylow + points_per_tile; ++y) {
      p += mandel(p, x, y, points_per_tile, tiles_per_row);
    }
  }
  rpc->result = NACL_SRPC_RESULT_OK;
  done->Run(done);
}
示例#4
0
文件: mandel.c 项目: tlepeche/Projets
void			mouse_mandel(int button, int x, int y, t_env *e)
{
	double	oldx;
	double	oldy;

	oldx = e->mouse_x;
	oldy = e->mouse_y;
	if (button == 4 || button == 5)
	{
		e->mouse_x = ((double)(x - W_WIDTH / 2) /
				(double)(W_WIDTH * e->zoom / 2)) + oldx;
		e->mouse_y = ((double)(y - W_HEIGHT / 2) /
				(double)(W_HEIGHT * e->zoom / 2)) + oldy;
	}
	if (button == 5)
	{
		if (e->zoom < 9223372036854775807 / 2)
			e->zoom *= 2;
		e->iter_max = sqrt(abs(2 * sqrt(abs(1 - sqrt(5 * e->zoom))))) * 50;
	}
	if (button == 4)
	{
		if (e->zoom > 1)
			e->zoom /= 2;
		e->iter_max = sqrt(abs(2 * sqrt(abs(1 - sqrt(5 * e->zoom))))) * 50;
	}
	mandel(e);
}
示例#5
0
int ComputeMandel::execute( const pair & p, my_context &c) const
{
    complex _tmp;
    c.m_data.get( p, _tmp );
    int depth = mandel( _tmp, c.max_depth );
    c.m_pixel.put(p,depth);
    return CnC::CNC_Success;
}
示例#6
0
int* synth_mandel(int width, int height, float minx, float maxx, float miny, float maxy) {
	int* bitmap = (int*)malloc(sizeof(int) * width * height);
	int i, j;
	for (i=0; i<height; i++) {
		float y = ((i * 1.0) / height) * (maxy - miny) + miny;
		for (j=0; j<width; j++) {
			float x = ((j * 1.0) / width) * (maxx - minx) + minx;
			int v = mandel(x, y, 250);
			int q = mandel(x, y, 10000);
			bitmap[i * width + j] = synth_color(v) + synth_color(q) * 256;
		}
		printf(".");
		fflush(stdout);
	}
	printf("\n");
	return bitmap;
}
示例#7
0
int main(void) {
    Image image;
    image.width = DIM;
    image.height = DIM;
    mandel(-1.25, -2, 1.25, 0.5, &image);
    save_image("mandelbrot.pnm", &image);
    return EXIT_SUCCESS;
}
示例#8
0
文件: perf.c 项目: ArchieCall/julia
int *mandelperf() {
    int *M = (int*) malloc(21*26*sizeof(int));
    for (int i = 0; i < 21; i++) {
        for (int j = 0; j < 26; j++) {
            M[26*i + j] = mandel((j-20)/10.0 + ((i-10)/10.0)*I);
        }
    }
    return M;
}
示例#9
0
文件: perf.c 项目: EvanMisshula/julia
int mandelperf() {
    int mandel_sum = 0;
    for (double re=-2.0; re<=0.5; re+=0.1) {
        for (double im=-1.0; im<=1.0; im+=0.1) {
            int m = mandel(re+im*I);
            mandel_sum += m;
        }
    }
    return mandel_sum;
}
示例#10
0
文件: perf.c 项目: CBaader/julia
int mandelperf() {
    int mandel_sum = 0;
    for (int re=-20; re<=5; re+=1) {
        for (int im=-10; im<=10; im+=1) {
            int m = mandel(re/10.0+I*im/10.0);
            mandel_sum += m;
        }
    }
    return mandel_sum;
}
示例#11
0
int main(int argc, char **argv)
{
    size_t width = strtoul(argv[1], NULL, 10);
    size_t height = strtoul(argv[2], NULL, 10);
    real_t cx = strtod(argv[3], NULL);
    real_t cy = strtod(argv[4], NULL);
    real_t scale = strtod(argv[5], NULL);
    size_t k = strtoul(argv[6], NULL, 10);
    
    uint8_t *buf = (uint8_t*)malloc(width*height*3);
    
    size_t i = 0;
    real_t x0 = cx - 4/(scale*2);
    real_t y0 = cy + 4/(scale*2);
    real_t dx = 4/(scale*width);
    real_t dy = 4/(scale*height);
    uint8_t r, g, b;
    
    for(size_t y = 0; y < height; y++) {
        for(size_t x = 0; x < width; x++) {
            real_t h = mandel(x0+x*dx, y0-y*dy, k);
            
            if(h < 0.0) {
                r = g = b = 0;
            }
            else {
		struct gradient_t *g0 = &grad[0];
                
                while(1) {
		    struct gradient_t *g1 = g0+1;
                    
                    if(h < g1->i) {
                        real_t p = (h - g0->i) / (g1->i - g0->i);
                        r = g0->c.r + (g1->c.r - g0->c.r) * p;
                        g = g0->c.g + (g1->c.g - g0->c.g) * p;
                        b = g0->c.b + (g1->c.b - g0->c.b) * p;
                        break;
                    }
                    else {
			g0 = g1;
                    }
                }                
            }
            
            buf[i++] = r;
            buf[i++] = g;
            buf[i++] = b;
        }
    }

    write(STDOUT_FILENO, buf, width*height*3);

    return 0;
}
示例#12
0
int main(int argc, char *argv[]) {
	int itermax = atoi(argv[2]);		/* how many iterations to do	*/
	double magnify=atof(argv[3]);		/* no magnification		*/
	int res = atoi(argv[1]);
	char *out = (char*) malloc(255 + res * res);

	mandel(out, res, itermax, magnify);
	free(out);

	printf("%s", out);
}
示例#13
0
文件: color.c 项目: tlepeche/Projets
void	choose_color(t_env *e)
{
	e->color = (e->color + 1) % 3;
	if (e->fract == 1)
		julia(e);
	if (e->fract == 2)
		mandel(e);
	if (e->fract == 3)
		tric(e);
	if (e->fract == 4)
		cub_julia(e);
	mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
}
示例#14
0
void MandelInfo::DoBatch(sInt b)
{
  for(sInt y=0;y<LinesPerBatch;y++)
  {
    sInt yy = (b*LinesPerBatch+y);
    sU32 *p = yy*Pitch + Data;
    for(sInt x=0;x<SizeX;x++)
    {
      sU8 c = sMin(255,mandel(px+sx*x/SizeX,py+sy*yy/SizeY,255));
      p[x] = (c<<0)|(c<<8)|(c<<16)|0xff000000;
    }
  }
}
示例#15
0
int main(int argc, char* argv[])
{
#ifdef IS_PARALLEL
  mpi::environment env(argc, argv);
  mpi::communicator world;

#ifdef TEST_OUTPUT
  printf ("I am process %d\n", world.rank ());
#endif
#endif

  int2D*	    matrix;			/* matrix to fill */
  int		nr, nc;			/* matrix size */
  real       base_x, base_y;
  real       ext_x, ext_y;

  nr = MAXEXT;
  nc = MAXEXT;
  base_x = 0;
  base_y = 0;
  ext_x = 1.5;
  ext_y = 1.5;

  matrix = new int2D[MAXEXT];

#ifdef TEST_TIME
  INT64 start, end;
  start = get_ticks ();
#endif

#ifdef IS_PARALLEL
  mandel_mpi (world, matrix, nr, nc, base_x, base_y, ext_x, ext_y);
#else
  mandel (matrix, nr, nc, base_x, base_y, ext_x, ext_y);
#endif

#ifdef TEST_TIME
  end = get_ticks ();
  print_elapsed_time (start, end);
#endif

#ifdef TEST_OUTPUT
  printf ("Mandelbrot set:\n");
  print_matrix (matrix, nr, nc);
#endif

  delete [] matrix;

  return 0;
}
示例#16
0
void mandlebrot(void *INP) {

  i_img *im;
  int i;
  i_img_dim x,y;
  int idx;
  
  double xs, ys;
  double div;

  i_color icl[256];
  srand(12235);
  for(i=1;i<256; i++) {
    icl[i].rgb.r = 100+(int) (156.0*rand()/(RAND_MAX+1.0));
    icl[i].rgb.g = 100+(int) (156.0*rand()/(RAND_MAX+1.0));
    icl[i].rgb.b = 100+(int) (156.0*rand()/(RAND_MAX+1.0));
  }

  icl[0].rgb.r = 0;
  icl[0].rgb.g = 0;
  icl[0].rgb.b = 0;
    

  
  if ( !getOBJ("image","Imager::ImgRaw",&im) ) { fprintf(stderr,"Error: image is missing\n"); }
  
  fprintf(stderr,"mandlebrot: parameters: (im %p)\n",im);

  fprintf(stderr, "mandlebrot: image info:\n size (" i_DFp ")\n channels (%d)\n",
	  i_DFcp(im->xsize,im->ysize),im->channels); 
  div = 2.5;

  xs = 0.8*div;
  ys = 0.5*div;
  
  div /= im->xsize;


  fprintf(stderr, "Divider: %f \n", div);
  for(y = 0; y < im->ysize; y ++) {
    for(x = 0; x < im->xsize; x ++ ) {
      idx = mandel(x*div-xs , y*div-ys);
      idx = (idx>255)?255:idx;
      i_ppix(im,x,y,&icl[idx]); 
    }
  }
}
示例#17
0
void* thread(void* pThreadNumber) {


   uint32_t* number = (uint32_t*) pThreadNumber;
   uint32_t begin = (height / numberOfThreads) * *number;
   uint32_t end = (height / numberOfThreads) * (*number+1);

   //fprintf(stderr,"Thread %d, begin height = %d, end heigh = %d\n", *number, begin , end);
   for(uint32_t h = begin; h < end; ++h) {
      for(uint32_t w = 0; w < height; ++w) {
         uint32_t iter = mandel(startX + w * delta, startY + h * delta, iterations);
         data[width * h + w] = iter;
      }
   }

	return NULL;		
}		
void mandelbrot_serial(float x0, float y0, float x1, float y1,
                       int width,int height, int maxIterations,
                       int output[])
{
    float dx = (x1 - x0) / width;
    float dy = (y1 - y0) / height;

    for (int j = 0; j < height; j++) {
        for (int i = 0; i < width; ++i) {
            float x = x0 + i * dx;
            float y = y0 + j * dy;

            int index = (j * width + i);
            output[index] = mandel(x, y, maxIterations);
        }
    }
}
示例#19
0
static void draw_mandel_line(ALLEGRO_BITMAP *bitmap, const Viewport *viewport,
   unsigned char palette[256][3], const int y)
{
   ALLEGRO_LOCKED_REGION *lr;
   unsigned char *rgb;
   double xlower, ylower;
   double xscale, yscale;
   double im;
   double re;
   int w, h;
   int x;
   int n = 512 / pow(2, viewport->zoom);

   w = al_get_bitmap_width(bitmap);
   h = al_get_bitmap_height(bitmap);

   if (!(lr = al_lock_bitmap_region(bitmap, 0, y, w, 1, ALLEGRO_PIXEL_FORMAT_ANY_24_NO_ALPHA,
         ALLEGRO_LOCK_WRITEONLY))) {
      abort_example("draw_mandel_line: al_lock_bitmap_region failed\n");
      return;
   }

   xlower = viewport->centre_x - viewport->x_extent / 2.0 * viewport->zoom;
   ylower = viewport->centre_y - viewport->y_extent / 2.0 * viewport->zoom;
   xscale = viewport->x_extent / w * viewport->zoom;
   yscale = viewport->y_extent / h * viewport->zoom;

   re = xlower;
   im = ylower + y * yscale;
   rgb = lr->data;

   for (x = 0; x < w; x++) {
      int i = mandel(re, im, n);
      int v = sin_lut[(int)(i * 64 / n)];

      rgb[0] = palette[v][0];
      rgb[1] = palette[v][1];
      rgb[2] = palette[v][2];
      rgb += 3;

      re += xscale;
   }

   al_unlock_bitmap(bitmap);
}
void mandelbrot_threads(float x0, float y0, float x1, float y1,
                       int width,int width_start, int width_end, int height, int maxIterations,
                       int output[])
{
    float dx = (x1 - x0) / width;
    float dy = (y1 - y0) / height;
    int flag=1;
    reset_and_start_timer();
    for (int j = 0; j < height; j++) {
        for (int i = width_start; i < width_end; ++i) {
            float x = x0 + i * dx;
            float y = y0 + j * dy;
            int index = (j * width + i);	    
            output[index] = mandel(x, y, maxIterations);
        }
    }
    double dt = get_elapsed_mcycles();
    printf("\n\t\t\t Thread took :\t[%.3f] millon cycles",dt);
}
示例#21
0
/*
 * Compute an entire pixmap of palette values.
 */
static void Compute(int xlo, int xhi, double xstart,
                    int ylo, int yhi, double ystart,
                    int width, char* map) {
  double x;
  double y;
  int i;
  int j;

  /* Compute the mandelbrot set, leaving color values in pixmap. */
  y = ystart;
  for (i = ylo; i < yhi; ++i) {
    x = xstart;
    for (j = xlo; j < xhi; ++j) {
      IND(map, width, i, j) = mandel(x, y);
      x += xstep;
    }
    y += ystep;
  }
}
示例#22
0
int main(void)
{
	int gen = 0;
	float scale = 0.25f, center_x = -0.5f, center_y = 0.0f;


	/* Clock setup */
	clock_setup();
	/* USART and GPIO setup */
	gpio_setup();
	/* Enable the SDRAM attached to the board */
	sdram_init();
	/* Enable the LCD attached to the board */
	lcd_init();

	printf("System initialized.\n");

	while (1) {
		/* Blink the LED (PG13) on the board with each fractal drawn. */
		gpio_toggle(GPIOG, GPIO13);		/* LED on/off */
		mandel(center_x, center_y, scale);	/* draw mandelbrot */
		lcd_show_frame();			/* show it */
		/* Change scale and center */
		center_x += 0.1815f * scale;
		center_y += 0.505f * scale;
		scale	*= 0.875f;
		gen++;
		if (gen > 99) {
			scale = 0.25f;
			center_x = -0.5f;
			center_y = 0.0f;
			gen = 0;
		}
		/*
		printf("Generation: %d\n", generation);
		printf("Cx, Cy = %9.2f, %9.2f, scale = %9.2f\n",
				center_x, center_y, scale);
		*/
	}

	return 0;
}
示例#23
0
void generate_png(coordinates coord, int depth, char *filename, color colors[], int numColors)
{
    int (*array)[coord.height][coord.width] = malloc(coord.height*coord.width*sizeof(int));

    for (int y=0; y<coord.height; y++)
    {
        for (int x=0; x<coord.width; x++)
        {
            double xValue = coord.x + (x * coord.xS);
            double yValue = coord.y - (y * coord.yS);
            (*array)[y][x] = mandel(xValue, yValue, depth);
        }
        printf("\r%i%% Complete", ((y+1)*100)/coord.height);
        fflush(stdout);
    }
    printf("\nWriting to file, %s.\n", filename);
    output_gd_png(*array, coord.width, coord.height, depth, filename, colors, numColors);

    free(*array);
}
示例#24
0
文件: main.c 项目: tlepeche/Projets
int		expose_hook(t_env *e)
{
	if (e->av[1] && ft_strcmp(e->av[1], "-j") == 0)
	{
		init_julia(e);
		julia(e);
	}
	else if (e->av[1] && ft_strcmp(e->av[1], "-m") == 0)
		mandel(e);
	else if (e->av[1] && ft_strcmp(e->av[1], "-t") == 0)
		tric(e);
	else if (e->av[1] && ft_strcmp(e->av[1], "-J") == 0)
	{
		init_cub_julia(e);
		cub_julia(e);
	}
	else
		print_command();
	mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
	return (0);
}
示例#25
0
void Mandel::calc(double deltax, double deltay, double scale, double iter) noexcept{
	const double ratio = xmax-xmin < ymax-ymin? (xmax-xmin)/width: (ymax-ymin)/height;
	const double nxmin = (xmax+xmin)/2-scale*(xmax-xmin)/2+ratio*deltax;
	const double nxmax = (xmax+xmin)/2+scale*(xmax-xmin)/2+ratio*deltax;
	const double nymin = (ymax+ymin)/2-scale*(ymax-ymin)/2+ratio*deltay;
	const double nymax = (ymax+ymin)/2+scale*(ymax-ymin)/2+ratio*deltay;
	xmin = nxmin;
	xmax = nxmax;
	ymin = nymin;
	ymax = nymax;
	nmax = static_cast<int>(nmax*iter);
	const int dist = std::min(width, height);
	double c, d;
	for(int i = 0; i < width; i += res){
		for(int j = 0; j < height; j += res){
			c = (xmin+xmax)/2+(xmax-xmin)*(i-width/2)/dist;
			d = (ymin+ymax)/2+(ymax-ymin)*(j-height/2)/dist;
			map[i][j] = mandel(c, d);
		}
	}
}
示例#26
0
int main(int argc, char *argv[])
{
	double n, x0, y0, dx, dy, x1, y1, x2, y2, t, g; 
	scanf("%lf%lf%lf%lf%lf", &n, &x0, &y0, &dx, &dy);
	
	double sc = (512.0 / n);
	double mx = 0.5*dx/n;
	double my = 0.5*dy/n;

	double y3 = y0;

	int r;
	int c;
	
	printf("%%!\n");
	printf("\t 50 50 translate\n");
	printf("\t 0 0 512 512 rectstroke\n");

	for (r = 0; r < n; r++)
	{
		
		y1 = y3;
		x1 = sc * r;
		for (c = 0; c < n; c++)
		{ 
			//x1 = sc * r;
			y1 = sc * c;
			x2 = x0 + mx;
			y2 = y0 + my;
			t = mandel(x2, y2);
			g = 1.0 - t / 255.0;
			printf("\t %.3f setgray %.3f %.3f %.3f %.3f rectfill\n", g, x1, y1, sc, sc);
			y0 += (2 * my);
		
		}
		x0 += (2 * mx);
	}

	printf("\t showpage\n");
}
//
// MandelbrotSerial --
//
// Compute an image visualizing the mandelbrot set.  The resulting
// array contains the number of iterations required before the complex
// number corresponding to a pixel could be rejected from the set.
//
// * x0, y0, x1, y1 describe the complex coordinates mapping
//   into the image viewport.
// * width, height describe the size of the output image
// * startRow, totalRows describe how much of the image to compute
void mandelbrotSerial(
    float x0, float y0, float x1, float y1,
    int width, int height,
    int startRow, int totalRows,
    int maxIterations,
    int output[])
{
    float dx = (x1 - x0) / width;
    float dy = (y1 - y0) / height;

    int endRow = startRow + totalRows;

    for (int j = startRow; j < endRow; j++) {
        for (int i = 0; i < width; ++i) {
            float x = x0 + i * dx;
            float y = y0 + j * dy;

            int index = (j * width + i);
            // printf("cur index %d\n", index);
            output[index] = mandel(x, y, maxIterations);
        }
    }
}
示例#28
0
文件: mandel.cpp 项目: t-weber/tlibs
int main()
{
	const int iXSize = 512;
	const int iYSize = 512;

	double dXScale = 1./iXSize * 2.;
	double dYScale = 1./iYSize * 2.;
	double dXOffs = -0.5;
	double dYOffs = 0.;


	std::ofstream ofstr("mandel.dat");

	for(int iY=0; iY<iYSize; ++iY)
	{
		for(int iX=0; iX<iXSize; ++iX)
		{
			t_cplx c((iX - iXSize/2)*dXScale + dXOffs,
				(iY - iYSize/2)*dYScale + dYOffs);
			unsigned int iIter = mandel(c);

			ofstr << std::setw(16) << iIter;
		}
		ofstr << "\n";

		std::cout << "Line " << iY << std::endl;
	}

	ofstr.flush();
	ofstr.close();


	std::system(("gnuplot -p -e \"set xrange [0:" + std::to_string(iXSize) + "];" +
			"set yrange [0:" + std::to_string(iYSize) + "];" +
			"plot 'mandel.dat' matrix with image\n\"").c_str());
	return 0;
}
示例#29
0
文件: mandel.c 项目: gitpan/Imager
void 
mandelbrot(i_img *im, double minx, double miny, double maxx, double maxy, int max_iter) {

  int i;
  i_img_dim x,y;
  int idx;
  double divx, divy;

  i_color icl[256];
  srand(12235);
  for(i=1;i<256; i++) {
    icl[i].rgb.r = 100+(int) (156.0*rand()/(RAND_MAX+1.0));
    icl[i].rgb.g = 100+(int) (156.0*rand()/(RAND_MAX+1.0));
    icl[i].rgb.b = 100+(int) (156.0*rand()/(RAND_MAX+1.0));
  }

  icl[0].rgb.r = 0;
  icl[0].rgb.g = 0;
  icl[0].rgb.b = 0;
    
  if (maxx <= minx)
    maxx = minx + 1.0;
  if (maxy <= miny)
    maxy = miny + 1.0;

  divx = (maxx - minx) / im->xsize;
  divy = (maxy - miny) / im->ysize;

  for(y = 0; y < im->ysize; y ++) {
    for(x = 0; x < im->xsize; x ++ ) {
      idx = mandel(minx + x*divx , miny + y*divy, max_iter);
      idx = idx % 256;
      i_ppix(im,x,y,&icl[idx]); 
    }
  }
}
示例#30
0
int main(void)
{
	float scale = 0.25f, centerX = -0.5f, centerY = 0.0f;

	clock_setup();
	gpio_setup();
	usart_setup();

	while (1) {
		/* Blink the LED (PD12) on the board with each fractal drawn. */
		gpio_toggle(GPIOD, GPIO12);	/* LED on/off */
		mandel(centerX,centerY,scale);	/* draw mandelbrot */

		/* Change scale and center */
		centerX += 0.175f * scale;
		centerY += 0.522f * scale;
		scale	*= 0.875f;

		usart_send_blocking(USART2, '\r');
		usart_send_blocking(USART2, '\n');
	}

	return 0;
}