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


C++ Colorf函数代码示例

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


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

示例1: Colorf

bool EditRectOP::onDraw() const
{
	if (ZoomViewOP::onDraw()) return true;

	if (m_captured.shape)
	{
		if (m_cmpt)
		{
			if (RectShape* rect = dynamic_cast<RectShape*>(m_captured.shape))
			{
				PrimitiveDraw::drawCircle(Vector(rect->m_rect.xCenter(), rect->m_rect.yCenter()), 
					m_cmpt->getNodeCaptureDistance(), true, 2, Colorf(0.4f, 1.0f, 0.4f));
				if (m_captured.pos.isValid())
					PrimitiveDraw::drawCircle(m_captured.pos, m_cmpt->getNodeCaptureDistance(), 
						true, 2, Colorf(1.0f, 0.4f, 0.4f));
			}
		}
	}
	else
	{
		if (m_firstPress.isValid() && m_currPos.isValid())
			PrimitiveDraw::drawRect(m_firstPress, m_currPos);
	}

	return false;
}
开发者ID:jjiezheng,项目名称:drag2d,代码行数:26,代码来源:EditRectOP.cpp

示例2: Colorf

bool EditBezierOP::onDraw() const
{
	if (ZoomViewOP::onDraw()) return true;

	if (m_captured.shape)
	{
		if (m_cmpt)
		{
			if (BezierShape* bezier = dynamic_cast<BezierShape*>(m_captured.shape))
			{
				PrimitiveDraw::drawCircle(Vector(bezier->getRect().xCenter(), bezier->getRect().yCenter()), 
					m_cmpt->getNodeCaptureDistance(), true, 2, Colorf(0.4f, 1.0f, 0.4f));
				if (m_captured.pos.isValid())
					PrimitiveDraw::drawCircle(m_captured.pos, m_cmpt->getNodeCaptureDistance(), 
					true, 2, Colorf(1.0f, 0.4f, 0.4f));
			}
		}
	}
	else
	{
		if (m_firstPress.isValid() && m_currPos.isValid())
		{
			BezierShape bezier(m_firstPress, m_currPos);
			bezier.draw();
		}
//			PrimitiveDraw::drawRect(m_firstPress, m_currPos);
	}

	return false;
}
开发者ID:jjiezheng,项目名称:drag2d,代码行数:30,代码来源:EditBezierOP.cpp

示例3: Colorf

Light::Light()
{
	m_diffuse			= Colorf(1,1,1);
	m_specular			= Colorf(1,1,1);
	m_ambient			= Colorf(0,0,0);
	m_intensity			= 1.f;
}
开发者ID:TheRyaz,项目名称:c_reading,代码行数:7,代码来源:Light.cpp

示例4: name

Colorf CVar::toColorf(bool* isValid) const
{
    if (m_type != Color)
    {
        if (com_developer && com_developer->toBoolean())
            orConsoleRef.print(orConsoleRef.Warning, "CVar %s is not a color", name().c_str());

        if (isValid != NULL)
            *isValid = false;

        return Colorf();
    }

    if (isValid != NULL)
        *isValid = true;

    int r, g, b, a;
    std::stringstream ss;

    ss << m_value;
    ss >> r;
    ss >> g;
    ss >> b;
    ss >> a;

    return Colorf(r*inv255, g*inv255, b*inv255, a*inv255);
}
开发者ID:Antidote,项目名称:Orion,代码行数:27,代码来源:CVar.cpp

示例5: create_window

bool FullScreen::update()
{

	const float virtual_screen_width = 800.0f;
	const float virtual_screen_height = 600.0f;
	game_time.update();

	// Check for fullscreen switch
	if (fullscreen_requested != is_fullscreen)
	{
		is_fullscreen = fullscreen_requested;
		create_window();
	}

	if (window.get_gc() != canvas.get_gc()) 
	{
		canvas = Canvas(window); // Always get the graphic context, the window may have been recreated
	}

	canvas.clear(Colorf(0.0f,0.0f,0.2f));

	int font_size = 28;
	font_size *= canvas.get_width() / virtual_screen_width;
	font.set_height(font_size);
	canvas.set_transform(Mat4f::identity());
	if (is_fullscreen)
	{
		font.draw_text(canvas, 16, font_size, "Full Screen Mode. Press 'F' to switch to resizable window.");
	}
	else
	{
		font.draw_text(canvas, 16, font_size, "Resizable Window. Press 'F' to switch to full screen mode.");
	}

	// Scale the drawing to the screen to a virtual screen size
	Mat4f matrix = Mat4f::scale( (float) canvas.get_width() / virtual_screen_width, (float) canvas.get_height() /virtual_screen_height, 1.0f);
	canvas.set_transform(matrix);

	spr_logo.draw(canvas, virtual_screen_width-spr_logo.get_width(), virtual_screen_height-spr_logo.get_height());

	spr_background.set_scale(0.5f, 0.5f);
	spr_background.draw(canvas, 100, 100);

	// Show a few alpha-blending moving rectangles that moves in circles
	float x = cos(sin_count)*120.0f;
	float y = sin(sin_count)*120.0f;
	sin_count += 2.0f * game_time.get_time_elapsed();
	canvas.fill_rect(Rectf( 320.0f + x -30.0f, 300.0f + y -30.0f, Sizef(60.0f, 60.0f)), Colorf(0.0f, 1.0f, 0.0, 0.5f));
	x = cos(sin_count+3.14159f)*120.0f;
	y = sin(sin_count+3.14159f)*120.0f;
	canvas.fill_rect(Rectf( 320.0f + x -30.0f, 300 + y -30.0f, Sizef(60.0f, 60.0f)), Colorf(1.0f, 1.0f, 0.0, 0.5f));

	window.flip(1);

	return !quit;
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:56,代码来源:fullscreen.cpp

示例6: Colorf

	ColorHSLx<float, Colorf>::operator Colorf()
	{
		float hue = min(359.0f, max(0.0f, h)) / 360.0f;
		float saturation = min(1.0f, max(0.0f, s));
		float lightness = min(1.0f, max(0.0f, l));
		if (saturation == 0.0f)
		{
			return Colorf(lightness, lightness, lightness, a);
		}

		float q;
		if (lightness < 0.5f)
		{
			q = lightness * (1 + saturation);
		}
		else
		{
			q = lightness + saturation - lightness * saturation;
		}
		float p = 2.0f * lightness - q;
		float temp_rgb[3];
		temp_rgb[0] = hue + 1.0f / 3.0f;
		temp_rgb[1] = hue;
		temp_rgb[2] = hue - 1.0f / 3.0f;
		for (auto & elem : temp_rgb)
		{
			while (elem < 0.0f)
			{
				elem += 1.0f;
			}
			while (elem > 1.0f)
			{
				elem -= 1.0f;
			}

			if (elem < (1.0f / 6.0f))
			{
				elem = p + (q - p) * 6.0f * elem;
			}
			else if (elem < 0.5f)
			{
				elem = q;
			}
			else if (elem < (2.0f / 3.0f))
			{
				elem = p + (q - p) * 6.0f * ((2.0f / 3.0f) - elem);
			}
			else
			{
				elem = p;
			}
		}
		return Colorf(temp_rgb[0], temp_rgb[1], temp_rgb[2], a);
	}
开发者ID:rombust,项目名称:UICore,代码行数:54,代码来源:color_hsl.cpp

示例7: Colorf

Colorf ChessPiece::getColor(Surface32f surface, Vec2i pixel)
{
	float r = *surface.getDataRed(pixel);
	float g = *surface.getDataGreen(pixel);
	float b = *surface.getDataBlue(pixel);
	return Colorf(r, g, b);
}
开发者ID:Runningblind3k,项目名称:Chess,代码行数:7,代码来源:ChessPiece.cpp

示例8: hsvToRgb

/////////////////////////////////////////////////////////////////////////////
// Utilities
Colorf hsvToRgb( const vec3 &hsv )
{
    float hue = hsv.x;
    float sat = hsv.y;
    float val = hsv.z;

    float x = 0.0f, y = 0.0f, z = 0.0f;
    
    if( hue == 1 ) hue = 0;
    else
		hue *= 6;

    int i = static_cast<int>( floorf( hue ) );
    float f = hue - i;
    float p = val * ( 1 - sat );
    float q = val* ( 1 - ( sat * f ) );
    float t = val* ( 1 - ( sat * ( 1 - f ) ) );

    switch( i ) {
		case 0: x = val; y = t; z = p; break;
		case 1: x = q; y = val; z = p; break;
		case 2: x = p; y = val; z = t; break;
		case 3: x = p; y = q; z = val; break;
		case 4: x = t; y = p; z = val; break;
		case 5: x = val; y = p; z = q; break;
    }

    return Colorf( x, y, z );
}
开发者ID:nselikoff,项目名称:Cinder,代码行数:31,代码来源:Color.cpp

示例9: Colorf

void BoxStyle::set_border_none()
{
    impl->border.left.type = BoxBorderValue::type_none;
    impl->border.left.color = Colorf();
    impl->border.left.width = 0.0f;
    impl->border.right.type = BoxBorderValue::type_none;
    impl->border.right.color = Colorf();
    impl->border.right.width = 0.0f;
    impl->border.top.type = BoxBorderValue::type_none;
    impl->border.top.color = Colorf();
    impl->border.top.width = 0.0f;
    impl->border.bottom.type = BoxBorderValue::type_none;
    impl->border.bottom.color = Colorf();
    impl->border.bottom.width = 0.0f;
    if (impl->style_changed) impl->style_changed();
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:16,代码来源:box_style.cpp

示例10: Colorf

void App::draw_font_example()
{
	int offset_x = 10;
	int offset_y = 600;
	int descender = (int) font_metrics.get_descent();

	// Surrounding box
	canvas.fill_rect(Rect(offset_x, offset_y+descender, offset_x + font_size.width, offset_y+descender - font_size.height), Colorf(0.0f, 0.0f, 0.0f));

	// Draw the external leading line
	int external_leading_offset = offset_y+font_metrics.get_external_leading() + font_metrics.get_descent();
	canvas.draw_line(offset_x, external_leading_offset, offset_x + font_size.width, external_leading_offset, Colorf(0.5f, 0.5f, 0.0f));

	// Draw the internal leading line
	int internal_leading_offset = offset_y - font_metrics.get_ascent() + font_metrics.get_internal_leading();
	canvas.draw_line(offset_x, internal_leading_offset, offset_x + font_size.width, internal_leading_offset, Colorf(0.5f, 0.5f, 0.0f));

	// Draw outline to the bounding box
	canvas.draw_line(offset_x, offset_y+descender, offset_x + font_size.width, offset_y+descender, Colorf(1.0f, 0.0f, 0.0f));
	canvas.draw_line(offset_x, offset_y+descender- font_size.height, offset_x + font_size.width, offset_y+descender - font_size.height, Colorf(1.0f, 0.0f, 0.0f));
	canvas.draw_line(offset_x + font_size.width, offset_y+descender, offset_x + font_size.width, offset_y+descender - font_size.height, Colorf(1.0f, 0.0f, 0.0f));
	canvas.draw_line(offset_x, offset_y+descender, offset_x, offset_y+descender - font_size.height, Colorf(1.0f, 0.0f, 0.0f));

	// Base line
	canvas.draw_line(offset_x, offset_y, offset_x + font_size.width, offset_y, Colorf(0.0f, 1.0f, 0.0f));

	selected_font.draw_text(canvas, offset_x, offset_y, font_text,  Colorf::white);
}
开发者ID:punkkeks,项目名称:ClanLib,代码行数:28,代码来源:font.cpp

示例11: radius_

CylinderMy::CylinderMy(double radius, const Point3d &base_center, const Point3d &top_center)
: radius_(radius)
, base_center_(base_center)
, top_center_(top_center)
, internal_rep_(NULL)
{
    facet_color_ = Colorf(0.0f, 0.0f, 0.0f, 1.0f);
}
开发者ID:LemonChiu,项目名称:Mesh-Skeleton-Tool,代码行数:8,代码来源:cylinder.cpp

示例12: Colorf

void PhysicsDebugDraw_Impl::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color)
{
	used_canvas->fill_rect(p.x-size,
					 p.y-size,
					 p.x+size,
					 p.y+size,
					 Colorf(color.r,color.g,color.b));
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:8,代码来源:physics_debug_draw_impl.cpp

示例13: PT

//Sets up some default lighting
void World::setup_lights() const
   {
   PT(AmbientLight) ambientLightPtr = new AmbientLight("ambientLight");
   PT(DirectionalLight) directionalLightPtr = new DirectionalLight("directionalLight");
   if(ambientLightPtr == NULL || directionalLightPtr == NULL)
      {
      nout << "ERROR: out of memory." << endl;
      return;
      }

   ambientLightPtr->set_color(Colorf(.4,.4,.35,1));
   directionalLightPtr->set_direction(LVector3f(0,8,-2.5));
   directionalLightPtr->set_color(Colorf(0.9,0.8,0.9,1));
   NodePath renderNp = m_windowFrameworkPtr->get_render();
   renderNp.set_light(renderNp.attach_new_node(directionalLightPtr));
   renderNp.set_light(renderNp.attach_new_node(ambientLightPtr));
   }
开发者ID:drivird,项目名称:drunken-octo-robot,代码行数:18,代码来源:world.cpp

示例14: Colorf

Sky::Sky() {
	turbidity = 10;

	// Initialize the Sun.
	sun_direction = Eigen::Vector3f(0, 20, 1);
	sun_direction.normalize();

	sun_power = Colorf(150e3, 150e3, 150e3);  // lx
}
开发者ID:xanxys,项目名称:construct,代码行数:9,代码来源:sky.cpp

示例15: drawGrid

void NanoApp::drawGrid (float size, float step)
{
   gl::color (Colorf (0.2f, 0.2f, 0.2f));
   for (float i = -size; i <= size; i += step)
   {
      gl::drawLine (vec3 (i, 0.0f, -size), vec3 (i, 0.0f, size));
      gl::drawLine (vec3 (-size, 0.0f, i), vec3 (size, 0.0f, i));
   }
}
开发者ID:neshume,项目名称:NanoguiBlock,代码行数:9,代码来源:NanoApp.cpp


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