Ejemplo n.º 1
0
void compute(fractal* f){
	int i, j;
	int sum = 0;
	for(i=0; i < fractal_get_height(f); i++){
		for(j=0; j < fractal_get_width(f); j++){
			fractal_compute_value(f,i,j);
			sum+=fractal_get_value(f,i,j);
		}
	}
	f->avg=(sum*1.0)/(f->height*f->width);
}
Ejemplo n.º 2
0
void test_libfractal_get_set_value() {
	fractal_t *ptr = fractal_new(name, 10, 10, a, b);
	int w = fractal_get_width(ptr);
	int h = fractal_get_height(ptr);
	int x = 0;
	int y = 0;
	for ( y = 0; y < h ; y++) {
		for( x = 0; x < w ; x++)  {
			fractal_set_value(ptr, x, y, x+y*10);
		}
	}

	for ( y = 0; y < h ; y++) {
		for( x = 0; x < w ; x++)  {
			CU_ASSERT_EQUAL(fractal_get_value(ptr, x, y), x+y*10);
		}
	}

	fractal_free(ptr);
}
Ejemplo n.º 3
0
void fractal_set_value(fractal_t *f, int x, int y, int val)
{
    int w = fractal_get_width(f);
    int offset = (x-1) + (y-1) * w;
    f->value[offset] = val;
}
Ejemplo n.º 4
0
int fractal_get_value(const fractal_t *f, int x, int y)
{
    int w = fractal_get_width(f);
    int offset = (x-1) + (y-1) * w;
    return f->value[offset];
}
Ejemplo n.º 5
0
void fractal_set_value(struct fractal *f, int x, int y, int val)
{
    int w = fractal_get_width(f);
    f->values[(w*y)+x] = val;
}
Ejemplo n.º 6
0
int fractal_get_value(const struct fractal *f, int x, int y)
{
    int w = fractal_get_width(f);
    return f->values[(y*w)+x];

}
Ejemplo n.º 7
0
void test_libfractal_get_width() {
	fractal_t *ptr = fractal_new(name, 42, height, a, b);
	CU_ASSERT_EQUAL(fractal_get_width(ptr), 42);
	fractal_free(ptr);
}