示例#1
0
文件: main.c 项目: lumirayz/Terragen
Uint32 to_pixel(SDL_PixelFormat *fmt, double value) {
	double v = (value + (double) 1) / (double) 2;
	int a = 255;
	double r, g, b;
	if(v <= 0.5) { // water
		double p = v / 0.5;
		r = 0;
		g = 0;
		b = __i(p, 0.5, 1);
	}
	else if(v <= 0.53) { // beach
		double p = (v - 0.5) / 0.03;
		p = sqrt(p);
		r = __i(p, 0, 1);
		g = __i(p, 0, 1);
		b = __i(p, 1, 0.5);
	}
	else if(v <= 0.56) { // to-grass
		double p = (v - 0.53) / 0.03;
		p = __c(p);
		r = __i(p, 1, 0.5);
		g = 1;
		b = 0.5;
	}
	else if(v <= 0.7) { // grass
		r = 0.5;
		g = 1;
		b = 0.5;
	}
	else if(v <= 0.71) { // to-mountain
		double p = (v - 0.7) / 0.01;
		r = 0.5;
		g = __i(p, 1, 0.5);
		b = 0.5;
	}
	else if(v <= 0.80) { // mountain
		double p = (v - 0.71) / 0.09;
		r = __i(p, 0.5, 1);
		g = __i(p, 0.5, 1);
		b = __i(p, 0.5, 1);
	}
	else { // snow
		r = 1;
		g = 1;
		b = 1;
	}
	return SDL_MapRGBA(fmt,
		(int)(r * (double) 255),
		(int)(g * (double) 255),
		(int)(b * (double) 255),
		a
	);
}
示例#2
0
文件: _debug.c 项目: 0-T-0/linux-sgx
inline bool  _STLP_CALL
stlp_in_range_aux(const _Iterator1& __it, const _Iterator& __first,
                  const _Iterator& __last, const bidirectional_iterator_tag &) {
  _Iterator1 __i(__first);
  for (;  __i != __last && __i != __it; ++__i);
  return (__i != __last);
}
示例#3
0
文件: _debug.c 项目: 0-T-0/linux-sgx
inline bool _STLP_CALL  stlp_in_range_aux(const _Iterator1& __it, const _Iterator& __first,
#endif
                                          const _Iterator& __last, const forward_iterator_tag &) {
  _Iterator1 __i(__first);
  for (;  __i != __last && __i != __it; ++__i);
  return (__i != __last);
}
示例#4
0
valarray<_Tp> valarray<_Tp>::operator[](const gslice& __slice) const {
  valarray<_Tp> __tmp(__slice._M_size(), _NoInit());
  if (__tmp.size() != 0) {
    _Gslice_Iter __i(__slice);
    do __tmp[__i._M_step] = (*this)[__i._M_1d_idx]; while(__i._M_incr());
  }
  return __tmp;
}
示例#5
0
valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<_Tp>& __x) {
  if (this->size() != 0) {
    _Gslice_Iter __i(__x._M_gslice);
    do
      (*this)[__i._M_step] = __x._M_array[__i._M_1d_idx];
    while(__i._M_incr());
  }
  return *this;
}