Example #1
0
File: Engine.cpp Project: aib/glito
void
Engine::iterBuildPoints( const Skeleton& skelet, const Zoom& zoom,
			Image& image, const int imax ) const {
    if ( Function::system == LINEAR ) {
	for ( int i = 1; i <= imax; ++i ) {
	    skelet.nextPoint( _x, _y, _color );
	    zoom.toScreen( _x, _y );
	    image.mem_plot( zoom.screenX, zoom.screenY );
	    image.mem_coul( zoom.screenX, zoom.screenY, _color );
	}
    } else if ( Function::system == FORMULA || Function::system == SINUSOIDAL ) {
	// since initial conditions are important, we have to give a new seed to the orbit
	_x = (float)rand()*2/RAND_MAX - 1;
	_y = (float)rand()*2/RAND_MAX - 1;
	skelet.setXY( _x, _y, _color ); // put the seed in the orbit
	for ( int i = 1; i <= imax; ++i ) {
	    skelet.nextPoint( _x, _y, _color );
	    zoom.toScreen( _x, _y );
	    image.mem_plot( zoom.screenX, zoom.screenY );
	    image.mem_coul( zoom.screenX, zoom.screenY, _color );
	    if ( i % 1000 == 0 ) {
		_x = (float)rand()*2/RAND_MAX - 1;
		_y = (float)rand()*2/RAND_MAX - 1;
		skelet.setXY( _x, _y, _color );
	    }
	}
    } else { // JULIA
	Julia& j = zoom.julia;
	for ( int i = 1; i <= imax; ++i ) {
	    skelet.nextPoint( _x, _y, _color );
	    zoom.toScreen( _x, _y );
	    j.handle( _x, _y, image.getHit( zoom.screenX, zoom.screenY ) );
	    image.mem_plot( zoom.screenX, zoom.screenY );
	    image.mem_coul( zoom.screenX, zoom.screenY, _color );
	}
    }
}