Пример #1
0
unsigned int	transroitor(t_inter *i, t_thr *f, t_pd *pd, int p)
{
	t_transroi	n;

	n.nat = 0;
	n.tmpcolor = 0x000000;
	n.mircolor = 0x000000;
	n.transcolor = 0x000000;
	t_inter_set(&n.transinter);
	t_inter_set(&n.mirinter);
	if ((n.nat += i->ref) > 0 && p < 100)
	{
		ref(f, i, &n, pd);
		n.mircolor = transroitor(&n.mirinter, f, &n.mirpd, p + 1);
		n.tmpcolor += color_mult(n.mircolor, i->ref, i->ref, i->ref);
	}
	if (i->trans > 0 && p < 8)
	{
		if ((n.i = trans_calculator(f, i, &n, pd)) == 0)
			n.transcolor = transroitor(&n.transinter, f, &n.transpd, p + 1);
		n.tmpcolor += color_mult(n.transcolor, i->trans, i->trans, i->trans);
	}
	n.nat += i->trans;
	if ((n.nat < 1) || p >= 8)
		n.tmpcolor += color_mult(amaterasu(f, i, 0),
			1 - n.nat, 1 - n.nat, 1 - n.nat);
	return (n.tmpcolor);
}
Пример #2
0
static XColor *GetShadowOrHiliteColor(
	Pixel background, float light, float dark, float factor)
{
	long brightness;
	unsigned int red, green, blue;

	memset(&color, 0, sizeof(color));
	color.pixel = background;
	XQueryColor(Pdpy, Pcmap, &color);
	red = color.red;
	green = color.green;
	blue = color.blue;

	brightness = BRIGHTNESS(red, green, blue);
	/* For "dark" backgrounds, make everything a fixed %age lighter */
	if (brightness < XmDEFAULT_DARK_THRESHOLD * PCT_BRIGHTNESS)
	{
		color.red = (unsigned short)
			(0xffff - ((0xffff - red) * dark + 50) / 100);
		color.green = (unsigned short)
			(0xffff - ((0xffff - green) * dark + 50) / 100);
		color.blue = (unsigned short)
			(0xffff - ((0xffff - blue) * dark + 50) / 100);
	}
	/* For "light" background, make everything a fixed %age darker */
	else if (brightness > XmDEFAULT_LIGHT_THRESHOLD * PCT_BRIGHTNESS)
	{
		color.red =
			(unsigned short)((red * light + 50) / 100);
		color.green =
			(unsigned short)((green * light + 50) / 100);
		color.blue =
			(unsigned short)((blue * light + 50) / 100);
	}
	/* For "medium" background, select is a fixed %age darker;
	 * top (lighter) and bottom (darker) are a variable %age
	 * based on the background's brightness
	 */
	else
	{
		color_mult(&color.red, &color.green, &color.blue, factor);
	}
	return &color;
}