コード例 #1
0
ファイル: core.c プロジェクト: jgan42/fractol
static int	fractol_core(t_fol *f)
{
	do_key(f);
	if (out_limits(f))
		exit(0);
	f->step = 1 / f->zoom;
	f->def_min.x = -f->mid.x / f->zoom;
	f->def_min.y = -f->mid.y / f->zoom;
	f->def_max.x = (WIN_H - f->mid.x) / f->zoom;
	f->def_max.y = (WIN_W - f->mid.y) / f->zoom;
	print_rules(f);
	print_param(f);
	if (f->type == 'j')
		julia(f);
	else if (f->type == 'b')
		buddha(f);
	else if (f->type == 'B')
		buddha2(f);
	else
		mandelbrot(f);
	mlx_put_image_to_window(f->mlx, f->win, f->im, 0, 0);
	return (1);
}
コード例 #2
0
/********************************************************************
 *  keyboard 
 *
 * Callback function called by GLUT when a key is pressed.
 * 
 *  Parameters:
 *  key - The key pressed.
 *  x, y - Mouse position when the key is pressed.
 *******************************************************/ 
void keyboard (unsigned char key, int x, int y)
{
    int i=0;
    char *o = "output.bmp";
    
    switch (key)        
    {
    //----Close the window
    case 'q':
    case 'Q':
    case 'x':
    case 'X':
        exit(0);

    //----increase budhabrot scale
    case '+':
        if (disp==BUDDHA)
            dark*=2;
        break;

    case '*':
        maxItr*=2;
        break;

    case '/':
        maxItr/=2;
        break;

    //----Fill the image with a single color
    case '1':     
        disp = MANDEL;
        break;


    //----Fill the image with a top-to-bottom color gradient
    case '2':
        disp = BUDDHA;
        break;

    //----create a patch of initial conditions to follow
    case '3':
        stepPatch();
        disp = PATCH;
        break;
    
    //print image to a file
    case 'p':
        rtWriteImage(pixels,o);
        /*CAREFUL THIS WRITES 100 images
        makePatch();
        for (i=0;i<100;i++)
        {
            stepPatch();
            patch();
            itoa(i,c,10);
            strcat(c,o);
            rtWriteImage(pixels,c);
        }
        */
        break;
    }

    if (disp==MANDEL)
        mandel();
    else if (disp==BUDDHA)
        buddha();
    else if (disp==PATCH)
        patch();

    //automatically call display
    glutPostRedisplay();
}