本文整理汇总了C++中color类的典型用法代码示例。如果您正苦于以下问题:C++ color类的具体用法?C++ color怎么用?C++ color使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了color类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_torchblock
void isometric_engine::render_torchblock(
image_operations_ptr o,
int bt,
pos_t px,
pos_t py,
color top,
color side
)
{
o->add_pixel(px, py, top);
o->add_pixel(px - 1, py, top);
top.lighten(0x20);
top.a -= 0xb0;
o->add_pixel(px, py + 1, top);
o->add_pixel(px - 1, py + 1, top);
o->add_pixel(px - 1, py + 1, side);
o->add_pixel(px - 1, py + 2, side);
side.lighten(0x20);
o->add_pixel(px, py + 1, side);
o->add_pixel(px, py + 2, side);
o->add_pixel(px - 2, py, top);
o->add_pixel(px + 1, py, top);
o->add_pixel(px, py - 1, top);
o->add_pixel(px - 1, py - 1, top);
}
示例2: foo
static color foo(color color, signed char degree)
{
if (degree < 0)
return color.blend(color::black(-degree));
else
return color.blend(color::white(+degree));
}
示例3: getColorInfo
inline std::vector<std::string> getColorInfo(const color & col, const color & otherColor,
bool getHeader = false, bool ansi = false){
if(getHeader){
return std::vector<std::string>{"hexStr", "hue", "sat", "lum", "alpha", "r;g;b", "r", "g", "b", "lastDiff", "closestAnsi"};
}else{
//"hexStr", "hue", "sat", "lum", "r;g;b", "lastDiff" ,"closestWord", "closestAnsi"
auto closeAnsi = getClosetAnsiColor(col);
if(ansi){
return std::vector<std::string>{estd::to_string(col.hexStr_), estd::to_string(col.hue_),
estd::to_string(col.lSat_), estd::to_string(col.lum_),
estd::to_string(col.alpha_), col.getRGBStr(),
estd::to_string(std::round(col.red_ * 255)),
estd::to_string(std::round(col.green_ * 255)),
estd::to_string(std::round(col.blue_ * 255)),
estd::to_string(otherColor.getHSLDistance(col)),
bib::bashCT::addBGColor(closeAnsi.first) + estd::to_string(closeAnsi.first) + bib::bashCT::reset
};
}else{
return std::vector<std::string>{estd::to_string(col.hexStr_), estd::to_string(col.hue_),
estd::to_string(col.lSat_), estd::to_string(col.lum_),
estd::to_string(col.alpha_), col.getRGBStr(),
estd::to_string(std::round(col.red_ * 255)),
estd::to_string(std::round(col.green_ *255)),
estd::to_string(std::round(col.blue_ *255)),
estd::to_string(otherColor.getHSLDistance(col)),
estd::to_string(closeAnsi.first)
};
}
}
}
示例4: return
inline bool operator==(color const& rhs) const
{
return (red_== rhs.red()) &&
(green_ == rhs.green()) &&
(blue_ == rhs.blue()) &&
(alpha_ == rhs.alpha());
}
示例5: parse_from_string
bool color_factory::parse_from_string(color & c, std::string const& css_color,
mapnik::css_color_grammar<std::string::const_iterator> const& g)
{
std::string::const_iterator first = css_color.begin();
std::string::const_iterator last = css_color.end();
// boost 1.41 -> 1.44 compatibility, to be removed in mapnik 2.1 (dane)
#if BOOST_VERSION >= 104500
bool result =
boost::spirit::qi::phrase_parse(first,
last,
g,
boost::spirit::ascii::space,
c);
return result && (first == last);
#else
mapnik::css css_;
bool result =
boost::spirit::qi::phrase_parse(first,
last,
g,
boost::spirit::ascii::space,
css_);
if (result && (first == last))
{
c.set_red(css_.r);
c.set_green(css_.g);
c.set_blue(css_.b);
c.set_alpha(css_.a);
return true;
}
return false;
#endif
}
示例6: overlay
color overlay(const color& fg, const color& bg) noexcept
{
if (opaque(fg) || transparent(bg)) return fg;
if (transparent(fg)) return bg;
return interpolate(bg, fg.alpha(), color{fg.red(), fg.green(), fg.blue()});
}
示例7: sizeof
void dx11render::renderLine(const point& begin, const point& end, const color& col)
{
if( m_device == NULL ) return;
UINT viewportNumber = 1;
D3D11_VIEWPORT vp;
m_deviceContext->RSGetViewports( &viewportNumber, &vp );
float xx0 = 2.0f * ( begin.getX() - 0.5f ) / vp.Width - 1.0f;
float yy0 = 1.0f - 2.0f * ( begin.getY() - 0.5f ) / vp.Height;
float xx1 = 2.0f * ( end.getX() - 0.5f ) / vp.Width - 1.0f;
float yy1 = 1.0f - 2.0f * ( end.getY() - 0.5f ) / vp.Height;
COLOR_VERTEX* v = NULL;
D3D11_MAPPED_SUBRESOURCE mapData;
if( FAILED( m_deviceContext->Map( m_pVertexBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &mapData ) ) )
return;
v = ( COLOR_VERTEX* ) mapData.pData;
v[0].Position.x = xx0;
v[0].Position.y = yy0;
v[0].Position.z = 0;
v[0].Color = col.toD3DXCOLOR();
v[1].Position.x = xx1;
v[1].Position.y = yy1;
v[1].Position.z = 0;
v[1].Color = col.toD3DXCOLOR();
m_deviceContext->Unmap( m_pVertexBuffer, NULL );
m_deviceContext->IASetInputLayout( m_pInputLayout );
UINT Stride = sizeof( COLOR_VERTEX );
UINT Offset = 0;
m_deviceContext->IASetVertexBuffers( 0, 1, &m_pVertexBuffer, &Stride, &Offset );
m_deviceContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP );
D3DX11_TECHNIQUE_DESC techDesc;
if( FAILED( m_pTechnique->GetDesc( &techDesc ) ) )
{
return;
}
for( UINT p = 0; p < techDesc.Passes; ++p )
{
m_pTechnique->GetPassByIndex( p )->Apply( 0, m_deviceContext );
m_deviceContext->Draw( 2, 0 );
}
}
示例8:
void CDX9Renderer::Line(point p1, point p2, const color& c1, const color& c2)
{
// No support for textured lines
SetTexture(NULL);
BeginBatch(batch_lines);
CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());
AddVertex(c1.getD3DCOLOR(), p1, 0.0f, 0.0f);
AddVertex(c2.getD3DCOLOR(), p2, 1.0f, 1.0f);
draw_op->vertex_count += 2;
}
示例9: SetTexture
void CDX9Renderer::Box(const rect& r, cr_float angle, point hotspot, const color& c)
{
// No support for textured lines
SetTexture(NULL);
quad q((r - hotspot).rotate_to_quad(angle, r.topleft()));
BeginBatch(batch_linestrip);
CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());
D3DCOLOR color = c.getD3DCOLOR();
// 4 vertices and use 5th index to repeat first vertex closing the strip as a box
AddVertex(color, q.tl, 0.0f, 0.0f);
AddVertex(color, q.tr, 0.0f, 0.0f);
AddVertex(color, q.br, 0.0f, 0.0f);
AddVertex(color, q.bl, 0.0f, 0.0f);
unsigned short index = draw_op->vertex_count;
AddIndex(index);
AddIndex(index + 1);
AddIndex(index + 2);
AddIndex(index + 3);
AddIndex(index);
draw_op->vertex_count += 4;
draw_op->index_count += 5;
}
示例10: rect_output_attributes
rect_output_attributes(const int x, const int y, const unsigned width, const unsigned height, color const& fill_color)
: x_(x),
y_(y),
width_(width),
height_(height),
fill_color_(fill_color.to_hex_string())
{}
示例11: fill
void surface::fill(rectangle rect,color col) {
SDL_Surface* ptr = get_low();
SDL_Rect r = rectangle::exchange_rect<SDL_Rect>(rect);
uint32_t c = col.map_rgba();
if(SDL_FillRect(ptr,&r,c)==-1)
throw exception_sdl();
}
示例12: blend
void color::blend(const color &other) {
if (other.is_invisible()) return;
r = alpha_over_c(other.r, other.a, r, a);
g = alpha_over_c(other.g, other.a, g, a);
b = alpha_over_c(other.b, other.a, b, a);
a = a + (other.a * (0xff - a)) / 0xff;
r = ((r * 0xff) / a);
g = ((g * 0xff) / a);
b = ((b * 0xff) / a);
}
示例13: set_background
virtual void set_background ( color& c )
{
m_background = &c;
XSetWindowBackground ( m_display, m_window, c.pixel() );
XClearWindow ( m_display, m_window );
XFlush ( m_display );
}
示例14: set_background
virtual void set_background ( color& c )
{
// hold a ref to the alloc'ed color
m_background.set ( c );
XSetWindowBackground ( m_display,
m_window,
c.pixel() );
refresh();
}
示例15: define_light
void display::define_light(const int & light_number, const math::transform & modelview, const math::vector & position,
const color & ambient, const color & diffuse, const color & specular,
const gsgl::real_t & attenuation_constant, const gsgl::real_t & attenuation_linear, const gsgl::real_t & attenuation_quadratic)
{
bind();
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelview.ptr());
int gl_light = GL_LIGHT0 + light_number;
glEnable(gl_light);
glLightfv(gl_light, GL_AMBIENT, ambient.ptr());
glLightfv(gl_light, GL_DIFFUSE, diffuse.ptr());
glLightfv(gl_light, GL_SPECULAR, specular.ptr());
glLightfv(gl_light, GL_POSITION, position.ptr());
glLightf(gl_light, GL_CONSTANT_ATTENUATION, attenuation_constant);
glLightf(gl_light, GL_LINEAR_ATTENUATION, attenuation_linear);
glLightf(gl_light, GL_QUADRATIC_ATTENUATION, attenuation_quadratic);
} // display::define_light()