本文整理汇总了C++中colour类的典型用法代码示例。如果您正苦于以下问题:C++ colour类的具体用法?C++ colour怎么用?C++ colour使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了colour类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: undefined_hue
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: undefined_hue
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
示例4: DrawPoint
void DrawPoint ( vec2 coord, float width, colour col )
{
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
SetColour(col);
Matrices::SetViewMatrix(matrix2x3::Identity());
Matrices::SetModelMatrix(matrix2x3::Identity());
float quad[8] = { coord.X(), coord.Y(),
coord.X(), coord.Y() - 2,
coord.X() + 2, coord.Y() - 2,
coord.X() + 2, coord.Y() };
glVertexPointer ( 2, GL_FLOAT, 0, quad );
glDrawArrays ( GL_QUADS, 0, 4 );
/* ¡WARNING! IMMEDIATE MODE! ENTER AT YOUR OWN RISK */
// glBegin(GL_POINTS);
// glVertex2f(coord.X(), coord.Y());
// glEnd();
}
开发者ID:prophile,项目名称:xsera,代码行数:26,代码来源:Graphics.cpp
示例5: colourToString
String PropertyHelper::colourToString(const colour& val)
{
using namespace std;
char buff[16];
sprintf(buff, "%.8X", val.getARGB());
return String(buff);
}
开发者ID:Ocerus,项目名称:Ocerus,代码行数:9,代码来源:CEGUIPropertyHelper.cpp
示例6: DrawLightning
void DrawLightning ( vec2 coordinate1, vec2 coordinate2, float width, float chaos, colour col, bool tailed )
{
uint32_t newLastSeed = lightningRNG.GetState();
RealDrawLightning(coordinate1, coordinate2, width, chaos, col, tailed, lightningRNG);
RNG localRNG(lastSeed);
lastSeed = newLastSeed;
col.alpha() *= 0.5f;
RealDrawLightning(coordinate1, coordinate2, width * 3.0f, chaos, col, tailed, localRNG);
}
开发者ID:prophile,项目名称:xsera,代码行数:9,代码来源:Graphics.cpp
示例7: RealDrawLightning
static void RealDrawLightning ( vec2 coordinate1, vec2 coordinate2, float width, float chaos, colour col, bool tailed, RNG& rng )
{
if (col.alpha() < 0.2f)
return;
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
glLineWidth(width);
Matrices::SetViewMatrix(matrix2x3::Identity());
Matrices::SetModelMatrix(matrix2x3::Identity());
SetColour(col);
unsigned long segments = 12;
float offsetting = chaos;
float* vertices = (float*)alloca(sizeof(float) * 2 * segments);
vec2 tangent = (coordinate2 - coordinate1).UnitVector();
vec2 normal = vec2(-tangent.Y(), tangent.X());
normal.X() = -normal.Y();
for (unsigned long i = 0; i < segments; i++)
{
float delta = ((float)i / (float)(segments - 1));
//This may be only a partial fix.
vec2 basePosition = ((coordinate1*(1.0f-delta)) + (coordinate2*delta));// / 2.0f;
if (tailed)
{
delta *= 2.0f;
if (delta > 1.0f) delta = 2.0f - delta;
}
float maxOffset = offsetting * delta;
float actualOffset = RandomFloat(-maxOffset, maxOffset);
basePosition += normal * actualOffset;
vertices[(i*2)+0] = basePosition.X();
vertices[(i*2)+1] = basePosition.Y();
}
glVertexPointer(2, GL_FLOAT, 0, vertices);
glDrawArrays(GL_LINE_STRIP, 0, segments);
}
开发者ID:prophile,项目名称:xsera,代码行数:43,代码来源:Graphics.cpp
示例8: colourToOGL
/*************************************************************************
convert colour value to whatever the OpenGL system is expecting.
*************************************************************************/
long OpenGLRenderer::colourToOGL(const colour& col) const
{
ulong cval;
#ifdef __BIG_ENDIAN__
cval = (static_cast<ulong>(255 * col.getAlpha()));
cval |= (static_cast<ulong>(255 * col.getBlue())) << 8;
cval |= (static_cast<ulong>(255 * col.getGreen())) << 16;
cval |= (static_cast<ulong>(255 * col.getRed())) << 24;
#else
cval = (static_cast<ulong>(255 * col.getAlpha())) << 24;
cval |= (static_cast<ulong>(255 * col.getBlue())) << 16;
cval |= (static_cast<ulong>(255 * col.getGreen())) << 8;
cval |= (static_cast<ulong>(255 * col.getRed()));
#endif
return cval;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:19,代码来源:openglrenderer.cpp
示例9: DrawCircle
void DrawCircle ( vec2 centre, float radius, float width, colour col )
{
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
glLineWidth(width);
Matrices::SetViewMatrix(matrix2x3::Translate(centre));
Matrices::SetModelMatrix(matrix2x3::Scale(radius));
SetColour ( col );
glVertexPointer(2, GL_FLOAT, 0, circlePoints);
glDrawArrays(GL_LINE_LOOP, 0, sizeof(circlePoints) / (2 * sizeof(float)));
}
开发者ID:prophile,项目名称:xsera,代码行数:19,代码来源:Graphics.cpp
示例10: DrawTriangle
void DrawTriangle ( const vec2 point1, const vec2 point2, const vec2 point3, colour col )
{
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
SetColour(col);
Matrices::SetViewMatrix(matrix2x3::Identity());
Matrices::SetModelMatrix(matrix2x3::Identity());
float real_triangle[6] = { point1.X(), point1.Y(),
point2.X(), point2.Y(),
point3.X(), point3.Y() };
glVertexPointer(2, GL_FLOAT, 0, real_triangle);
glDrawArrays(GL_POLYGON, 0, 3);
}
开发者ID:prophile,项目名称:xsera,代码行数:21,代码来源:Graphics.cpp
示例11: DrawLine
void DrawLine ( vec2 coordinate1, vec2 coordinate2, float width, colour col )
{
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
glLineWidth(width);
Matrices::SetViewMatrix(matrix2x3::Identity());
Matrices::SetModelMatrix(matrix2x3::Identity());
SetColour(col);
float vertices[4] = { coordinate1.X(), coordinate1.Y(),
coordinate2.X(), coordinate2.Y() };
glVertexPointer ( 2, GL_FLOAT, 0, vertices );
glDrawArrays ( GL_LINES, 0, 2 );
}
开发者ID:prophile,项目名称:xsera,代码行数:21,代码来源:Graphics.cpp
示例12: DrawDiamond
void DrawDiamond ( float top, float left, float bottom, float right, colour col )
{
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
SetColour(col);
Matrices::SetViewMatrix(matrix2x3::Identity());
Matrices::SetModelMatrix(matrix2x3::Identity());
float diamond[8] = { (right + left) / 2, top,
left, (top + bottom) / 2,
(right + left) / 2, bottom,
right, (top + bottom) / 2 };
glVertexPointer(2, GL_FLOAT, 0, diamond);
glDrawArrays(GL_QUADS, 0, 4);
}
开发者ID:prophile,项目名称:xsera,代码行数:22,代码来源:Graphics.cpp
示例13: DrawBox
void DrawBox ( float top, float left, float bottom, float right, float width, colour col )
{
SetShader("Primitive");
DisableTexturing();
if (col.alpha() < 1.0f)
{
EnableBlending();
}
else
{
DisableBlending();
}
Matrices::SetViewMatrix(matrix2x3::Identity());
Matrices::SetModelMatrix(matrix2x3::Identity());
SetColour(col);
float quad[8] = { left, top,
left, bottom,
right, bottom,
right, top };
glVertexPointer ( 2, GL_FLOAT, 0, quad );
glDrawArrays ( GL_QUADS, 0, 4 );
if (width != 0)
{
SetColour(col + colour(0.45, 0.45, 0.45, 0.0));
glLineWidth(width);
float vertices[16] = { left, top,
right, top,
left, top,
left, bottom,
right, top,
right, bottom,
left, bottom,
right, bottom };
glVertexPointer ( 2, GL_FLOAT, 0, vertices );
glDrawArrays ( GL_LINES, 0, 8 );
}
}
开发者ID:prophile,项目名称:xsera,代码行数:37,代码来源:Graphics.cpp
注:本文中的colour类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论