当前位置: 首页>>代码示例>>C++>>正文


C++ colour::red方法代码示例

本文整理汇总了C++中colour::red方法的典型用法代码示例。如果您正苦于以下问题:C++ colour::red方法的具体用法?C++ colour::red怎么用?C++ colour::red使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在colour的用法示例。


在下文中一共展示了colour::red方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: from_rgb

	hsl_colour hsl_colour::from_rgb(const colour& aColour)
	{
		double hue, saturation, lightness;
		double r = aColour.red() / 255.0, g = aColour.green() / 255.0, b = aColour.blue() / 255.0;
		double M = std::max(std::max(r, g), b);
		double m = std::min(std::min(r, g), b);
		double c = M - m;
		double h2;
		if (c == 0.0)
			h2 = undefined_hue();
		else if (M == r)
			h2 = std::fmod((g - b) / c, 6.0);
		else if (M == g)
			h2 = (b - r) / c + 2.0;
		else if (M == b)
			h2 = (r - g) / c + 4.0;
		else
			h2 = undefined_hue();
		if (h2 != undefined_hue())
		{
			hue = 60.0 * h2;
			if (hue < 0.0)
				hue += 360.0;
		}
		else
			hue = undefined_hue();
		lightness = 0.5f * (M + m);
		lightness = std::max(std::min(lightness, 1.0), 0.0);
		if (c == 0.0)
			saturation = 0.0;
		else
			saturation = c / (1.0 - std::abs(2.0 * lightness - 1.0));
		saturation = std::max(std::min(saturation, 1.0), 0.0);
		return hsl_colour(hue, saturation, lightness);
	}
开发者ID:basisbit,项目名称:neogfx,代码行数:35,代码来源:hsl_colour.cpp

示例2: from_rgb

	hsv_colour hsv_colour::from_rgb(const colour& aColour)
	{
		double hue, saturation, value;
		double r = aColour.red() / 255.0, g = aColour.green() / 255.0, b = aColour.blue() / 255.0;
		double M = std::max(std::max(r, g), b);
		double m = std::min(std::min(r, g), b);
		double c = M - m;
		double h2;
		if (c == 0.0)
			h2 = undefined_hue();
		else if (M == r)
			h2 = std::fmod((g - b) / c, 6.0);
		else if (M == g)
			h2 = (b - r) / c + 2.0;
		else if (M == b)
			h2 = (r - g) / c + 4.0;
		else
			h2 = undefined_hue();
		if (h2 != undefined_hue())
		{
			hue = 60.0 * h2;
			if (hue < 0.0)
				hue += 360.0;
		}
		else
			hue = undefined_hue();
		value = M;
		value = std::max(std::min(value, 1.0), 0.0);
		if (c == 0.0)
			saturation = 0.0;
		else
			saturation = c / value;
		saturation = std::max(std::min(saturation, 1.0), 0.0);
		return hsv_colour(hue, saturation, value, aColour.alpha() / 255.0);
	}
开发者ID:FlibbleMr,项目名称:neogfx,代码行数:35,代码来源:hsv_colour.cpp

示例3: SetColour

static void SetColour ( const colour& col )
{
	if (sizeof(col) == sizeof(float) * 4)
	{
		glColor4fv((const GLfloat*)&col);
	}
	else
	{
		glColor4f(col.red(), col.green(), col.blue(), col.alpha());
	}
}
开发者ID:prophile,项目名称:xsera,代码行数:11,代码来源:Graphics.cpp


注:本文中的colour::red方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。