• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ color类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了color类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Ben0mega,项目名称:c10t,代码行数:31,代码来源:isometric_engine.cpp


示例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));
 }
开发者ID:goalizc,项目名称:takisy,代码行数:7,代码来源:color_scheme.cpp


示例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)
						};
		}
	}
}
开发者ID:,项目名称:,代码行数:30,代码来源:


示例4: return

 inline bool operator==(color const& rhs) const
 {
     return (red_== rhs.red()) &&
            (green_ == rhs.green()) &&
            (blue_  == rhs.blue()) &&
            (alpha_ == rhs.alpha());
 }
开发者ID:cquest,项目名称:mapnik,代码行数:7,代码来源:color.hpp


示例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
}
开发者ID:novldp,项目名称:mapnik,代码行数:33,代码来源:color.cpp


示例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()});
}
开发者ID:1726184339,项目名称:code,代码行数:7,代码来源:color.cpp


示例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 );
		}
	}
开发者ID:,项目名称:,代码行数:54,代码来源:


示例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;
	}
开发者ID:segafan,项目名称:Construct-classic,代码行数:12,代码来源:CDX9Renderer_Batch.cpp


示例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;
	}
开发者ID:segafan,项目名称:Construct-classic,代码行数:28,代码来源:CDX9Renderer_Batch.cpp


示例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())
 {}
开发者ID:DavidLiuGitHub,项目名称:mapnik,代码行数:7,代码来源:svg_output_attributes.hpp


示例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();
	}
开发者ID:nicolas-van,项目名称:codeyong,代码行数:7,代码来源:sdlw_surface.cpp


示例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);
}
开发者ID:NateLogan,项目名称:c10t,代码行数:10,代码来源:color.cpp


示例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 );
      }
开发者ID:WileyECoyote,项目名称:dilithium,代码行数:10,代码来源:label.hpp


示例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();

	}
开发者ID:8l,项目名称:x11,代码行数:12,代码来源:window.hpp


示例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()
开发者ID:kulibali,项目名称:periapsis,代码行数:21,代码来源:display.cpp


示例16: sizeof

void
linux_framebuffer::setcolor(const color & c)
{
	if(m_var.bits_per_pixel == 16)
	{
		//printf("R %d %d\n", m_var.red.offset, m_var.red.length);
		//printf("G %d %d\n", m_var.green.offset, m_var.green.length);
		//printf("B %d %d\n", m_var.blue.offset, m_var.blue.length);
		//printf("A %d %d\n", m_var.transp.offset, m_var.transp.length);

		constexpr size_t sizeof_colorcomponent = sizeof(c.ir()) * 8;
		const uint16_t r = (c.ir() >> (sizeof_colorcomponent - m_var.red.length)) << m_var.red.offset;
		const uint16_t g = (c.ig() >> (sizeof_colorcomponent - m_var.green.length)) << m_var.green.offset;
		const uint16_t b = (c.ib() >> (sizeof_colorcomponent - m_var.blue.length)) << m_var.blue.offset;
		const uint16_t a = (c.ia() >> (sizeof_colorcomponent - m_var.transp.length)) << m_var.transp.offset;

		//printf("assign %08x + %08x = %08x\n", m_map, offset, pos);
		m_col16 = r|g|b|a;
	}

}
开发者ID:roeles,项目名称:icarus2,代码行数:21,代码来源:linux_framebuffer.cpp


示例17: config_error

void color_factory::init_from_string(color & c, std::string const& css_color)
{
    typedef std::string::const_iterator iterator_type;
    typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;

    css_color_grammar g;
    iterator_type first = css_color.begin();
    iterator_type 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);
    if (!result)
    {
        throw config_error(std::string("Failed to parse color value: ") +
                           "Expected a CSS color, but got '" + css_color + "'");
    }
#else
    mapnik::css css_;
    bool result =
        boost::spirit::qi::phrase_parse(first,
                                        last,
                                        g,
                                        boost::spirit::ascii::space,
                                        css_);
    if (!result)
    {
        throw config_error(std::string("Failed to parse color value: ") +
                           "Expected a CSS color, but got '" + css_color + "'");
    }
    c.set_red(css_.r);
    c.set_green(css_.g);
    c.set_blue(css_.b);
    c.set_alpha(css_.a);
#endif
}
开发者ID:novldp,项目名称:mapnik,代码行数:40,代码来源:color.cpp


示例18: draw_radial_marks

   void draw_radial_marks(canvas& cnv, circle cp, float size, color c)
   {
      using namespace radial_consts;
      auto state = cnv.new_state();
      auto center = cp.center();
      constexpr auto num_divs = 50;
      float div = range / num_divs;
      auto const& theme = get_theme();

      cnv.translate({ center.x, center.y });
      cnv.stroke_style(theme.ticks_color);
      for (int i = 0; i != num_divs+1; ++i)
      {
         float from = cp.radius;
         if (i % (num_divs / 10))
         {
            // Minor ticks
            from -= size / 4;
            cnv.line_width(theme.minor_ticks_width);
            cnv.stroke_style(c.level(theme.minor_ticks_level));
         }
         else
         {
            // Major ticks
            cnv.line_width(theme.major_ticks_width);
            cnv.stroke_style(c.level(theme.major_ticks_level));
         }

         float angle = offset + (M_PI / 2) + (i * div);
         float sin_ = std::sin(angle);
         float cos_ = std::cos(angle);
         float to = cp.radius - (size / 2);

         cnv.move_to({ from * cos_, from * sin_ });
         cnv.line_to({ to * cos_, to * sin_ });
         cnv.stroke();
      }
   }
开发者ID:cycfi,项目名称:photon,代码行数:38,代码来源:dial.cpp


示例19: map_palette

color map_palette(const color& c, int palette)
{
    if(palette < 0 || palette >= palettes.size() || palettes[palette].mapping.empty()) {
        return c;
    }

    const std::map<uint32_t,uint32_t>& mapping = palettes[palette].mapping;
    std::map<uint32_t,uint32_t>::const_iterator i = mapping.find(c.value());
    if(i != mapping.end()) {
        return color(color::convert_pixel_byte_order(i->second));
    } else {
        return c;
    }
}
开发者ID:,项目名称:,代码行数:14,代码来源:


示例20: ASSERT

	void d3d9_prim2d_lines::render_segments(const vec2* points, unsigned int point_count, const color& color) {
		ASSERT(_is_rendering);

		if (point_count > 1) {
			static_assert(sizeof(solar::vec2) == sizeof(D3DXVECTOR2), "solar::vec2 cannot be casted to D3DXVECTOR2");
			auto d3dx_points = reinterpret_cast<const D3DXVECTOR2*>(points);

			if (_viewport.X != 0 || _viewport.Y != 0) {
				//NOTE: ID3DXLine will internally transform all the points by the viewport's top left position. This causes problems because
				//all clients expect the points to be in screen space, not in the current viewport space.
				D3DMATRIX old_projection;
				D3D9_VERIFY(_context.get_device()->GetTransform(D3DTS_PROJECTION, &old_projection));
				D3DXMATRIX new_projection;
				::D3DXMatrixTranslation(&new_projection, -uint_to_float(_viewport.X), -uint_to_float(_viewport.Y), 0.f);
				new_projection *= old_projection;
				D3D9_VERIFY(_context.get_device()->SetTransform(D3DTS_PROJECTION, &new_projection));
				D3D9_VERIFY(_d3dx_line->Draw(d3dx_points, point_count, color.to_argb32()));
				D3D9_VERIFY(_context.get_device()->SetTransform(D3DTS_PROJECTION, &old_projection));
			}
			else {
				D3D9_VERIFY(_d3dx_line->Draw(d3dx_points, point_count, color.to_argb32()));
			}
		}
	}
开发者ID:jseward,项目名称:solar,代码行数:24,代码来源:d3d9_prim2d_lines.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ color_ostream类代码示例发布时间:2022-05-31
下一篇:
C++ codet类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap