コード例 #1
0
ファイル: mandel.c プロジェクト: cokesme/f1rmware
void mandelPixel(int x, int y) {
    long r0,i0,rn, p,q;
    long rs,is;
    int iteration;

    rs=(mandel.rmax-mandel.rmin)/RESY;
    is=(mandel.imax-mandel.imin)/RESX;
    //p=fixpt(mandel.rmin+y*rs);
    //q=fixpt(mandel.imin+x*is);
    p=mandel.rmin+y*rs;
	q=mandel.imin+x*is;

	rn=0;
    r0=0;
    i0=0;
    iteration=0;
    while ((mul(rn,rn)+mul(i0,i0))<fixpt(4) && ++iteration<ITERATION_MAX)  {
        rn=mul((r0+i0),(r0-i0)) +p;
        i0=mul(fixpt(2),mul(r0,i0)) +q;
        r0=rn;
    }
    if (iteration==ITERATION_MAX) iteration=ITERATION_MAX;
    bool pixel = ( iteration>1);
    lcdSetPixel(x, y, 255-iteration*2);
}
コード例 #2
0
// calculate the current mandelbrot set
static void calculate_mandel()
{		
	const GR_COLOR * the_palette = GRAY_palette;

	const int sx = screen_width;
	const int sy = screen_height;
	const int iter = iterations-1;
	
	const double xmin=xMin;
	const double ymin=yMin;
	const double xmax=xMax;
	const double ymax=yMax;

	const double xs=(xmax-xmin)/sx;
	const double ys=(ymax-ymin)/sy;

	register long x0,y0,p,q,xn,tot;
	register int i=0,x=0,y=0;

	const int depth = current_depth;

	if( screen_info.bpp == 16 )
		the_palette = color_palette;
	
	rendering=1;
	show_cursor=0;
	active_renderer++;
	
	// start main loop
	for (y=0;y<sy;y++) {
		for (x=0;x<sx;x++) { 
			p=fixpt(xmin+x*xs);
			q=fixpt(ymin+y*ys);
			xn=0;
			x0=0;
			y0=0;
			i=0;
			while ((mul(xn,xn)+mul(y0,y0))<fixpt(4) && ++i<iter)  {
				xn=mul((x0+y0),(x0-y0)) +p;
				y0=mul(fixpt(2),mul(x0,y0)) +q;
				x0=xn;
			}
			tot+=i;
		
			GrSetGCForeground(mandel_gc, the_palette[i%8]);
			GrPoint(level[depth].mandel_buffer, mandel_gc,x,y);
		}
		
		// for every line only:
		// check if we had an event
		check_event();
		// check if we need to quit
		if (!rendering) return;
		// update the screen
		draw_mandel();
	}
	// end main loop
	
	active_renderer--;
}
コード例 #3
0
ファイル: mandel.c プロジェクト: cokesme/f1rmware
void mandelInit() {
    //mandel.rmin = -2.2*0.9;
    //mandel.rmax = 1.0*0.9;
    //mandel.imin = -2.0*0.9;
    //mandel.imax = 2.0*0.9;
    mandel.rmin = fixpt(-2);
    mandel.rmax = fixpt(1);
    mandel.imin = fixpt(-2);
    mandel.imax = fixpt(2);
    mandel.presscount = 0;
    mandel.presslimitzin = 15;
    mandel.presslimitzout = 5;
    mandel.zoomlevel = 0;
    mandel.maxzoomin = 42;
    mandel.maxzoomout = -12;

    mandel.dirty = true;
    mandel.dup = false;
    mandel.ddown = false;
    mandel.dleft = false;
    mandel.dright = false;
    mandel.clickmark = false;
}