コード例 #1
0
ファイル: mandelbrot.c プロジェクト: mhawes/wstealmandel
/* -------------------------------------------------------------------------- */
void compute_plane( Complex *c_max, 
                    Complex *c_min, 
                    Complex *c_factor)
{
    unsigned int x, y;
    Complex c_cur;      /* used as the current z value */
    
    static char plane[HEIGHT][WIDTH];  /* array to hold the generated image */

    /* classic nested for loop approach */
    for(y = 0; y < HEIGHT; y++)    
    {
        c_cur.im = convert_y_coord( c_max->im, c_factor->im, y);
        
        for(x = 0; x < WIDTH; x++)
        {
            c_cur.re = convert_x_coord( c_min->re, c_factor->re, x);
            
            if( is_outside_rad2( &c_cur)){
                plane[y][x] = MAX_ITERATIONS / 2;  /* make the outer grey */
            }
            else{
                /* compute c_cur checking if it is in the set */
                plane[y][x] = is_member( c_cur);
            }
        }
    }
    
    /* write it out to a PPM file */
    write_to_ppm( plane);
}
コード例 #2
0
Pen_Pos_FL_t screen_coords(j_window_t i_window, Pen_Pos_t i_pos){
	return Pen_Pos_FL_t(convert_x_coord(i_window, i_pos.first), convert_y_coord(i_window, i_pos.second));
}