Exemplo n.º 1
0
float sample_wave(float freq, float coord, float pixsize)
{
	float fac, frac,  retval;
	int part1, part2;
	
	if(pixsize > freq) return 0.5;
	
	pixsize/= freq;
	
	fac= coord/freq;
	part1= ffloor(fac);
	frac= fac - part1;

	if(part1 & 1) retval= 0.0;
	else retval= 1.0;
	
	if(pixsize != 0.0) {
		
		/* is coord+pixsize another value? */
		
		part2= ffloor(fac + pixsize);
		if(part1==part2) return retval;
		
		/* antialias */	
		if(retval==1.0) retval= (1.0-frac)/pixsize;
		else retval= 1.0-(1.0-frac)/pixsize;
	}
	return retval;
}
Exemplo n.º 2
0
double Gdal::Band::GetDoubleAt(Pointf pt) const
{
	Pointf src = pt * owner.GetInverseTransform();
	int x = ffloor(src.x);
	int y = ffloor(src.y);
	if(x < 0 || x >= size.cx || y < 0 || y >= size.cy)
		return Null;
	return GetDouble(x, y);
}
Exemplo n.º 3
0
char *proobraz(char* input)
{
input = registr(input);

input=  ficha(input);
for (int i=0;i<strlen(input);i++)
    {
       ssin(i,input);
       ccos(i,input);
       aasin(i,input);
       aacos(i,input);
       aatan(i,input);
       cceil(i,input);
       cch(i,input);
       eexp(i,input);
       aabs(i,input);
       ffloor(i,input);
       lln(i,input);
       llog(i,input);
       ssh(i,input);
       ssqrt(i,input);
       ttan(i,input);
       tth(i,input);
       cctg(i,input);
	aactg(i,input);
	ccth(i,input);
    }
    return input;
}
Exemplo n.º 4
0
bool  ScrollBar::Set(int apagepos) {
	int op = pagepos;
	pagepos = apagepos;
	if(pagepos > totalsize - pagesize) pagepos = totalsize - pagesize;
	if(pagepos < 0) pagepos = 0;
	int slsize = GetRange();
	int mint = max(minthumb, style->thumbmin);
	if(totalsize <= 0)
		SetThumb(0, slsize);
	else {
		double thumbsize = slsize * pagesize / (double) totalsize;
		double rest = slsize * pagesize - thumbsize * totalsize;
		double ts, ps;
		if(thumbsize >= slsize || thumbsize < 0) {
			ts = slsize;
			ps = 0;
		}
		else
		if(thumbsize <= mint) {
			ps = ((slsize - mint) * (double)pagepos + rest) / (double) (totalsize - pagesize);
			ts = mint;
		}
		else {
			ps = (slsize * (double)pagepos + rest) / (double) totalsize;
			ts = thumbsize;
		}
		SetThumb(ffloor(ps), fceil(ts));
    }
	if(pagepos != op) {
		Refresh();
		WhenScroll();
		return true;
	}
	return false;
}
Exemplo n.º 5
0
void HSVtoRGB(double h, double s, double v, double& r, double& g, double& b)
{
	if(s == 0)
	{
		r = g = b = v;
		return;
	}
	double rem = fmod(h *= 6, 1);
	double p = v * (1 - s);
	double q = v * (1 - s * rem);
	double t = v * (1 - s * (1 - rem));
	switch(ffloor(h))
	{
	default: NEVER(); // invalid color!
	case 6:
	case 0: r = v; g = t; b = p; break;
	case 1: r = q; g = v; b = p; break;
	case 2: r = p; g = v; b = t; break;
	case 3: r = p; g = q; b = v; break;
	case 4: r = t; g = p; b = v; break;
	case -1:
	case 5: r = v; g = p; b = q; break;
	}
}