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


C++ Color函数代码示例

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


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

示例1: Color

void View::SetBackColor(int a, int r, int g, int b)
{
	_backcolor = Color(a, r, g, b);
}
开发者ID:beatwise,项目名称:wisegui-library,代码行数:4,代码来源:view.cpp

示例2: switch

void CollisionPolygon2D::_notification(int p_what) {


	switch(p_what) {
		case NOTIFICATION_ENTER_TREE: {
			unparenting=false;
			can_update_body=get_tree()->is_editor_hint();
			if (!get_tree()->is_editor_hint()) {
				//display above all else
				set_z_as_relative(false);
				set_z(VS::CANVAS_ITEM_Z_MAX-1);
			}

		} break;
		case NOTIFICATION_EXIT_TREE: {
			can_update_body=false;
		} break;
		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {

			if (!is_inside_tree())
				break;
			if (can_update_body) {
				_update_parent();
			} else if (shape_from>=0 && shape_to>=0) {
				CollisionObject2D *co = get_parent()->cast_to<CollisionObject2D>();
				for(int i=shape_from;i<=shape_to;i++) {
					co->set_shape_transform(i,get_transform());
				}
			}


		} break;

		case NOTIFICATION_DRAW: {

			if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) {
				break;
			}


			for(int i=0;i<polygon.size();i++) {

				Vector2 p = polygon[i];
				Vector2 n = polygon[(i+1)%polygon.size()];
				draw_line(p,n,Color(0.9,0.2,0.0,0.8),3);
			}
//#define DEBUG_DECOMPOSE
#if defined(TOOLS_ENABLED) && defined (DEBUG_DECOMPOSE)

			Vector< Vector<Vector2> > decomp = _decompose_in_convex();

			Color c(0.4,0.9,0.1);
			for(int i=0;i<decomp.size();i++) {

				c.set_hsv( Math::fmod(c.get_h() + 0.738,1),c.get_s(),c.get_v(),0.5);
				draw_colored_polygon(decomp[i],c);
			}
#else
			draw_colored_polygon(polygon,get_tree()->get_debug_collisions_color());
#endif


		} break;
		case NOTIFICATION_UNPARENTED: {
			unparenting = true;
			_update_parent();
		} break;

	}
}
开发者ID:Scrik,项目名称:godot,代码行数:70,代码来源:collision_polygon_2d.cpp

示例3: WriteLog

void Output::WarningStr(std::string const& warn) {
	WriteLog("Warning", warn, Color(255, 255, 0, 255));
}
开发者ID:Zegeri,项目名称:Player,代码行数:3,代码来源:output.cpp

示例4: mat_area

RES Light::_get_gizmo_geometry() const {


    Ref<FixedMaterial> mat_area( memnew( FixedMaterial ));

    mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.7,0.6,0.0,0.05) );
    mat_area->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.7,0.7,0.7) );
    mat_area->set_blend_mode( Material::BLEND_MODE_ADD );
    mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,true);
    mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);

    Ref<FixedMaterial> mat_light( memnew( FixedMaterial ));

    mat_light->set_parameter( FixedMaterial::PARAM_DIFFUSE, Color(1.0,1.0,0.8,0.9) );
    mat_light->set_flag(Material::FLAG_UNSHADED,true);

    Ref< Mesh > mesh;

    Ref<SurfaceTool> surftool( memnew( SurfaceTool ));

    switch(type) {

    case VisualServer::LIGHT_DIRECTIONAL: {


        mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.9,0.8,0.1,0.8) );
        mat_area->set_blend_mode( Material::BLEND_MODE_MIX);
        mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,false);
        mat_area->set_flag(Material::FLAG_UNSHADED,true);

        _make_sphere( 5,5,0.6, surftool );
        surftool->set_material(mat_light);
        mesh=surftool->commit(mesh);

        //		float radius=1;

        surftool->begin(Mesh::PRIMITIVE_TRIANGLES);

        const int arrow_points=5;
        Vector3 arrow[arrow_points]= {
            Vector3(0,0,2),
            Vector3(1,1,2),
            Vector3(1,1,-1),
            Vector3(2,2,-1),
            Vector3(0,0,-3)
        };

        int arrow_sides=4;


        for(int i = 0; i < arrow_sides ; i++) {


            Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
            Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);


            for(int j=0; j<arrow_points-1; j++) {

                Vector3 points[4]= {
                    ma.xform(arrow[j]),
                    mb.xform(arrow[j]),
                    mb.xform(arrow[j+1]),
                    ma.xform(arrow[j+1]),
                };

                Vector3 n = Plane(points[0],points[1],points[2]).normal;

                surftool->add_normal(n);
                surftool->add_vertex(points[0]);
                surftool->add_normal(n);
                surftool->add_vertex(points[1]);
                surftool->add_normal(n);
                surftool->add_vertex(points[2]);

                surftool->add_normal(n);
                surftool->add_vertex(points[0]);
                surftool->add_normal(n);
                surftool->add_vertex(points[2]);
                surftool->add_normal(n);
                surftool->add_vertex(points[3]);


            }


        }

        surftool->set_material(mat_area);
        mesh=surftool->commit(mesh);



    }
    break;
    case VisualServer::LIGHT_OMNI: {


        _make_sphere( 20,20,vars[PARAM_RADIUS],  surftool );
        surftool->set_material(mat_area);
//.........这里部分代码省略.........
开发者ID:JoeSwangion,项目名称:godot,代码行数:101,代码来源:light.cpp

示例5: ERR_FAIL_INDEX_V

Color Light::get_color(LightColor p_color) const {

    ERR_FAIL_INDEX_V(p_color, 3, Color());
    return colors[p_color];

}
开发者ID:JoeSwangion,项目名称:godot,代码行数:6,代码来源:light.cpp

示例6: al_start_timer

	void SceneManager::run()
	{	
		m_devices->setSceneMessenger(this);
#ifdef CGE_MOBILE
       //ALLEGRO_JOYSTICK *joystick = NULL;
       // al_reconfigure_joysticks();
        //joystick=al_get_joystick(al_get_num_joysticks()-1);
#endif
        
		al_start_timer(m_gameTimer);

		//is the event handled?
		bool handled = false;
		ALLEGRO_EVENT next;
		bool skip = false;
		double numFrames = 1;
		double totalDelta = 0.0f;

		int frames = 0;
		double starttime = 0;
		bool first = true;
		float fps = 0.0f;
        
		//main loop
		while(m_gameIsRunning)
		{
			handled = false;
			al_wait_for_event(queue,&evt);

			bool hasNext = al_peek_next_event(queue,&next);
			if(hasNext && next.type == ALLEGRO_EVENT_TIMER)
			{
				al_drop_next_event(queue);
			}
			//render the scene
			if(m_canDraw && m_needsRedraw && al_is_event_queue_empty(queue))
			{
				if(skip)
					skip = false;
				else
				{
					double a = al_get_time();

					if(m_currentScene->canRender())
					{
						m_g.begin();
						m_currentScene->render();
						/*
						m_g.drawText(StringUtil::toString(fps),m_devices->getFontManager()->getDefaultFont(),agui::Color(0,0,0),-2,-2,0);
						m_g.drawText(StringUtil::toString(fps),m_devices->getFontManager()->getDefaultFont(),agui::Color(0,0,0),2,2,0);
						m_g.drawText(StringUtil::toString(fps),m_devices->getFontManager()->getDefaultFont(),agui::Color(255,255,255),0,0,0);
						*/
						if(m_needsTransition)
						{
							m_needsTransition = false;
							m_transitioning = true;
						}
						if(m_transitioning)
							m_g.drawTintedSprite(m_g.getBuffer(),
							Color(m_transitionOpacity,m_transitionOpacity,m_transitionOpacity,m_transitionOpacity),0,0,0);
						m_g.end();
					}

					double t = al_get_time();
					if (first)
					{
						frames = 0;
						starttime = t;
						first = false;
						continue;
					}
					frames++;
					if (t - starttime > 0.25 && frames > 10)
					{
						fps = (double) frames / (t - starttime);
						starttime = t;
						frames = 0;
					}
                    
					m_needsRedraw = false;
                    
                    if(!m_transitioning && m_needFirstRender) {
                        m_needFirstRender = false;
                        m_callOnNextLogic = true;
                        m_nextLogicFrames = 0;
                    }

					double delta = al_get_time() - a;
					totalDelta += delta;
					numFrames++;
					double avgDelta = totalDelta / numFrames;

					if(numFrames > 100)
					{
						numFrames = 0;
						totalDelta = 0;
					}
                    if(avgDelta > (1.0f / 40.0f) || Platf::isMini())
						skip = true;
				}
//.........这里部分代码省略.........
开发者ID:jmasterx,项目名称:StemwaterSpades,代码行数:101,代码来源:SceneManager.cpp

示例7: MOZ_ASSERT

bool
TextureClientD3D11::Lock(OpenMode aMode)
{
  if (!IsAllocated()) {
    return false;
  }
  MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");

  if (mTexture) {
    MOZ_ASSERT(!mTexture10);
    mIsLocked = LockD3DTexture(mTexture.get());
  } else {
    MOZ_ASSERT(!mTexture);
    mIsLocked = LockD3DTexture(mTexture10.get());
  }
  if (!mIsLocked) {
    return false;
  }

  if (NS_IsMainThread()) {
    // Make sure that successful write-lock means we will have a DrawTarget to
    // write into.
    if (aMode & OpenMode::OPEN_WRITE) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
    }

    if (mNeedsClear) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
      mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
      mNeedsClear = false;
    }
    if (mNeedsClearWhite) {
      mDrawTarget = BorrowDrawTarget();
      if (!mDrawTarget) {
        Unlock();
        return false;
      }
      mDrawTarget->FillRect(Rect(0, 0, GetSize().width, GetSize().height), ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
      mNeedsClearWhite = false;
    }
  }

  return true;
}
开发者ID:diorahman,项目名称:gecko-dev,代码行数:52,代码来源:TextureD3D11.cpp

示例8: dc

	void CGDIPracticeView::OnDraw(CDC* pDC)
	{
		CClientDC dc(this);			//Client DC를 얻는다.

		// Client Rect를 얻는다.
		CRect rClientRect;
		GetClientRect(&rClientRect);

		// Bitmap 생성
		Bitmap mBitmap(rClientRect.Width(), rClientRect.Height());

		// Graphics를 얻는다.
		Graphics graphics(dc);

		// 비트맵을 메모리 내에서 그릴 그래픽 생성
		Graphics memGraphics(&mBitmap);

		// 화면을 흰색 바탕으로 그리기 위한 브러쉬
		SolidBrush drawBrush(Color(255,255,255));

		// 검은색 컬러 지정
		Color drawColor(255,0,0,0);

		// 팬 생성
		Pen drawPen(drawColor, 1);
		drawPen.SetStartCap(LineCapRound);
		drawPen.SetEndCap(LineCapRound);

		// bitmap을 흰색으로 칠한다(line같은 경우 이미지가 남기 때문에)
		memGraphics.FillRectangle(&drawBrush, 0,0,rClientRect.Width(), rClientRect.Height());

		int componentSize = m_components.GetSize();
		CString str;
		str.Format(_T("size : %d\n"), componentSize);
		TRACE(str);
		for (int i = 0; i < componentSize; i++)
		{
			// 컴포넌트의 팬 설정
			drawColor.SetFromCOLORREF(m_components.GetAt(i)->m_colorPen);
			drawPen.SetColor(drawColor);
			drawPen.SetWidth((float)m_components.GetAt(i)->m_nPenSize);

			// 얕은 복사
			CDrawComponent *component = m_components.GetAt(i);

			switch (component->m_nDrawMode)
			{
				// 지우개인 경우
			case DRAW_NONE:
				{
					// 팬의 브러쉬 색을 흰색으로 변경
					drawBrush.SetColor(drawColor);

					// 지우개를 사용한 좌표를 순차적으로 다시 그린다.
					int pointSize = component->m_points.GetSize();
					for (int j = 0; j < pointSize; j++)
					{
						// 흰색의 지우개 사각형을 그린다. 
						memGraphics.FillRectangle(&drawBrush, component->m_points.GetAt(j).X, component->m_points.GetAt(j).Y,
							component->m_nEraserSize * 2, component->m_nEraserSize * 2);
					}
					break;
				}
			case LINE_MODE:
				memGraphics.DrawLine(&drawPen, component->m_ptStart.x, component->m_ptStart.y,
					component->m_ptEnd.x, component->m_ptEnd.y);
				break;
			case RECT_MODE:
			{
				// 우측 아래
				if(component->m_ptStart.x < component->m_ptEnd.x && component->m_ptStart.y < component->m_ptEnd.y)
					memGraphics.DrawRectangle(&drawPen, component->m_ptStart.x, component->m_ptStart.y,
					component->m_ptEnd.x - component->m_ptStart.x, component->m_ptEnd.y - component->m_ptStart.y);
				// 우측 위
				else if(component->m_ptStart.x < component->m_ptEnd.x && component->m_ptStart.y > component->m_ptEnd.y)
					memGraphics.DrawRectangle(&drawPen, component->m_ptStart.x, component->m_ptEnd.y,
					component->m_ptEnd.x - component->m_ptStart.x, component->m_ptStart.y - component->m_ptEnd.y);
				// 좌측 아래
				else if(component->m_ptStart.x > component->m_ptEnd.x && component->m_ptStart.y < component->m_ptEnd.y)
					memGraphics.DrawRectangle(&drawPen, component->m_ptEnd.x, component->m_ptStart.y,
					component->m_ptStart.x - component->m_ptEnd.x, component->m_ptEnd.y - component->m_ptStart.y);
				// 좌측 위
				else
					memGraphics.DrawRectangle(&drawPen, component->m_ptEnd.x, component->m_ptEnd.y,
					component->m_ptStart.x - component->m_ptEnd.x, component->m_ptStart.y - component->m_ptEnd.y);

				break;
			}
			case CIRCLE_MODE:
				memGraphics.DrawEllipse(&drawPen, component->m_ptStart.x, component->m_ptStart.y,
					component->m_ptEnd.x - component->m_ptStart.x, component->m_ptEnd.y - component->m_ptStart.y);
				break;
			case FREE_MODE:
				if (component->m_points.GetSize() > 1)
				{
					// 자유선의 작은 선들을을 순차적으로 하나씩 그린다.
					int pointSize = component->m_points.GetSize();
					for (int j = 1; j < pointSize; j++)
						memGraphics.DrawLine(&drawPen, component->m_points.GetAt(j - 1).X, component->m_points.GetAt(j - 1).Y,
						component->m_points.GetAt(j).X, component->m_points.GetAt(j).Y);
//.........这里部分代码省略.........
开发者ID:formfoxk,项目名称:DrawingBoard,代码行数:101,代码来源:GDIPracticeView.cpp

示例9: Draw

void RenderTarget::Draw(GLint x, GLint y, GLfloat rotation, GLfloat scaleX, GLfloat scaleY, GLfloat alpha, GLint xx, GLint yy, GLint w, GLint h)
{
	Draw(x, y, rotation, scaleX, scaleY, Color(255, 255, 255), alpha, xx, yy, w, h);
}
开发者ID:Landeplage,项目名称:Amigo,代码行数:4,代码来源:RenderTarget.cpp

示例10: Color

	  1060000, 10, 17, 0, true, 0
	},{
	  Lang::SMALL_PLASMA_ACCEL,0,
	  Equip::SLOT_LASER, 9, {},
	  12000000, 22, 50, 0, true, 0
	},{
	  Lang::LARGE_PLASMA_ACCEL,0,
	  Equip::SLOT_LASER, 10, {},
	  39000000, 50, 100, 0, true, 0
	}
};

const LaserType Equip::lasers[] = {
	{
		0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0,
		Color(0.0f, 0.0f, 0.0f, 0.0f),
	},{		// 1mw pulse
		1.0f, 10000.0f, 1000.0f, 0.25f, 30.0f, 5.0f, 0,
		Color(1.0f, 0.2f, 0.2f, 1.0f),
	},{		// 1mw df pulse
		1.0f, 10000.0f, 1000.0f, 0.25f, 30.0f, 5.0f, Equip::LASER_DUAL,
		Color(1.0f, 0.2f, 0.2f, 1.0f),
	},{	// 2mw pulse
		1.0f, 10000.0f, 2000.0f, 0.25f, 30.0f, 5.0f, 0,
		Color(1.0f, 0.5f, 0.2f, 1.0f),
	},{	// 2mw rf pulse
		1.0f, 10000.0f, 2000.0f, 0.13f, 30.0f, 5.0f, 0,
		Color(1.0f, 0.5f, 0.2f, 1.0f),
	},{		// 4mw pulse
		1.0f, 10000.0f, 4000.0f, 0.25f, 30.0f, 5.0f, 0,
		Color(1.0f, 1.0f, 0.2f, 1.0f),
开发者ID:HeadHunterEG,项目名称:pioneer,代码行数:31,代码来源:EquipType.cpp

示例11: ColorEsc

Color ColorEsc(EscValue v)
{
	return v.IsVoid() ? Color(Null) : Color(v.GetFieldInt("r"), v.GetFieldInt("g"), v.GetFieldInt("b"));
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:4,代码来源:laylib.cpp

示例12: get_display_color

Color get_display_color(unsigned int i) {
  // from http://colorbrewer2.org/
  static const Color all[] = {Color(166 / 255., 206. / 255., 227. / 255.),
                              Color(31. / 255., 120. / 255., 180. / 255.),
                              Color(178. / 255., 223. / 255., 138. / 255.),
                              Color(51. / 255., 160. / 255., 44. / 255.),
                              Color(251. / 255., 154. / 255., 153. / 255.),
                              Color(227. / 255., 26. / 255., 28. / 255.),
                              Color(253. / 255., 191. / 255., 111. / 255.),
                              Color(255. / 255., 127. / 255., 0. / 255.),
                              Color(202. / 255., 178. / 255., 214. / 255.),
                              Color(106. / 255., 61. / 255., 154. / 255.),
                              Color(255. / 255., 255. / 255., 153. / 255.)};
  static const int size = sizeof(all) / sizeof(Color);
  return all[i % size];
}
开发者ID:newtonjoo,项目名称:imp,代码行数:16,代码来源:Color.cpp

示例13: Color

void CGeneralWindow::Paint(float x, float y, float w, float h)
{
	if (m_flFadeToBlack)
	{
		float flAlpha = (float)RemapVal(GameServer()->GetGameTime(), m_flFadeToBlack, m_flFadeToBlack+1.5f, 0.0, 1.0);
		glgui::CRootPanel::PaintRect(0, 0, glgui::CRootPanel::Get()->GetWidth(), glgui::CRootPanel::Get()->GetHeight(), Color(0, 0, 0, (int)(255*flAlpha)));
		return;
	}

	Rect recAntivirus = m_hAntivirus.GetArea("Antivirus");
	glgui::CBaseControl::PaintSheet(m_hAntivirus.GetSheet("Antivirus"), x, y, w, h, recAntivirus.x, recAntivirus.y, recAntivirus.w, recAntivirus.h, m_hAntivirus.GetSheetWidth("Antivirus"), m_hAntivirus.GetSheetHeight("Antivirus"));

	BaseClass::Paint(x, y, w, h);

	if (!m_sEmotion.length())
		return;

	CGameRenderingContext c(GameServer()->GetRenderer(), true);
	c.SetBlend(BLEND_ALPHA);
	c.SetColor(Color(255, 255, 255, 255));

	Rect recEmotion = m_hGeneral.GetArea(m_sEmotion);
	glgui::CBaseControl::PaintSheet(m_hGeneral.GetSheet(m_sEmotion), x, y, 256, 256, recEmotion.x, recEmotion.y, recEmotion.w, recEmotion.h, m_hGeneral.GetSheetWidth(m_sEmotion), m_hGeneral.GetSheetHeight(m_sEmotion));

	if ((m_bHelperSpeaking || m_bProgressBar) && Oscillate((float)GameServer()->GetGameTime(), 0.2f) > 0.5)
	{
		Rect recMouth = m_hGeneralMouth.GetArea(m_sEmotion);
		glgui::CBaseControl::PaintSheet(m_hGeneralMouth.GetSheet(m_sEmotion), x, y, 256, 256, recMouth.x, recMouth.y, recMouth.w, recMouth.h, m_hGeneralMouth.GetSheetWidth(m_sEmotion), m_hGeneralMouth.GetSheetHeight(m_sEmotion));
	}

	if (m_bProgressBar)
	{
		double flTime = 3;
		glgui::CBaseControl::PaintRect(x + m_pText->GetLeft(), y + 160, m_pText->GetWidth(), 10, Color(255, 255, 255, 255));
		glgui::CBaseControl::PaintRect(x + m_pText->GetLeft() + 2, y + 160 + 2, ((m_pText->GetWidth() - 4) * (float)RemapValClamped(GameServer()->GetGameTime(), m_flStartTime, m_flStartTime+flTime, 0.0, 1.0)), 10 - 4, Color(42, 65, 122, 255));

		static tstring sEstimate;
		static double flLastEstimateUpdate = 0;

		if (!sEstimate.length() || GameServer()->GetGameTime() - flLastEstimateUpdate > 1)
		{
			int iRandomTime = RandomInt(0, 5);
			tstring sRandomTime;
			if (iRandomTime == 0)
				sRandomTime = "centuries";
			else if (iRandomTime == 1)
				sRandomTime = "minutes";
			else if (iRandomTime == 2)
				sRandomTime = "hours";
			else if (iRandomTime == 3)
				sRandomTime = "days";
			else
				sRandomTime = "seconds";

			sEstimate = tsprintf(tstring("Estimated time remaining: %d %s"), RandomInt(2, 100), sRandomTime.c_str());

			flLastEstimateUpdate = GameServer()->GetGameTime();
		}

		float flWidth = glgui::RootPanel()->GetTextWidth(sEstimate, sEstimate.length(), "sans-serif", 12);
		glgui::CLabel::PaintText(sEstimate, sEstimate.length(), "sans-serif", 12, x + m_pText->GetLeft() + m_pText->GetWidth()/2 - flWidth/2, (float)y + 190, Color(0, 0, 0, 255));
	}
}
开发者ID:BSVino,项目名称:Digitanks,代码行数:63,代码来源:general_window.cpp

示例14: get_gray_color

Color get_gray_color(double f) {
  static Color colors[] = {Color(0, 0, 0), Color(1, 1, 1)};
  return get_color_map_color(f, colors, sizeof(colors) / sizeof(Color));
}
开发者ID:newtonjoo,项目名称:imp,代码行数:4,代码来源:Color.cpp

示例15: ASSERT

void ButtonGadget::onRender( RenderContext & context, const RectInt & window )
{
	WindowButton::onRender( context, window );

	// get a pointer to our gadget
	NounGadget * pGadget = m_Gadget;
	if ( pGadget != NULL )
	{
		DisplayDevice * pDisplay = context.display();
		ASSERT( pDisplay );
		GameDocument * pDoc = (GameDocument *)document();
		ASSERT( pDoc );
		WindowStyle * pStyle = windowStyle();
		ASSERT( pStyle );
		Font * pFont = pStyle->font();
		ASSERT( pFont );

		// display bar if gadget has delay before usabled
		int delay = pGadget->usableWhen();
		if ( delay > 0 )
		{
			if ( (pDoc->tick() % 10) < 6 )		// make the bar blink
			{
				RectInt bar( window.left, window.top, 
					window.right - ((window.width() * delay) / 100), window.top + 16 );

				PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::ADDITIVE );
				PrimitiveWindow::push( pDisplay, bar, WINDOW_UV, Color(0,0,255,255) );
			}			
		}

		// draw the gadget icon
		Material * pIcon = pGadget->icon();
		if ( pIcon != NULL )
		{
			RectInt iconBox( PointInt( window.left, window.top ), SizeInt( 32, 16 ) );

			Material::push( context, pIcon );
			PrimitiveWindow::push( pDisplay, iconBox, WINDOW_UV, m_IconColor );
		}

		// display any gadget status text
		WideString sStatus( pGadget->status() );
		if ( sStatus.length() > 0 )
		{
			SizeInt stringSize( pFont->size( sStatus ) );
			Font::push( pDisplay, pFont, PointInt( window.m_Right - stringSize.width, window.top ), sStatus, YELLOW );
		}

		// display hotkey in lower-left corner of button
		CharString sHotKey;
		if ( pGadget->hotkey() != 0 && pGadget->hotkey() != HK_SPACE )
			sHotKey += keyText( Keyboard::unmap( pGadget->hotkey() ) );

		if ( m_Gadget->group() != 0 )
			sHotKey += CharString().format(" %c", m_Gadget->group() );

		if ( WidgetCast<GadgetBeamWeapon>( pGadget ) && ((GadgetBeamWeapon *)pGadget)->pointDefense() )
			sHotKey += " PD";

		if ( sHotKey.length() > 0 )
		{
			WideString sWide = sHotKey;
			SizeInt stringSize( pFont->size( sWide ) );

			Font::push( pDisplay, pFont, PointInt( window.m_Right - stringSize.width, window.m_Bottom - stringSize.height ), 
				sWide, YELLOW );
		}

		// display the damage bar
		if ( pGadget->damage() > 0 )
		{
			if ( (pDoc->tick() % 10) < 6 )		// make the bar blink
			{
				float damage = pGadget->damageRatioInv();
				RectInt bar( window.m_Left, window.m_Bottom + 1, 
					window.m_Right - (window.width() * (1.0f - damage)), window.m_Bottom + 3 );

				Color barColor( 255 * (1.0f - damage), 255 * damage,0,255 );
				PrimitiveMaterial::push( pDisplay, PrimitiveMaterial::NONE );
				PrimitiveWindow::push( pDisplay, bar, WINDOW_UV, barColor );
			}
		}

		// blink a white border if this is the current target
		if ( pDoc->target() == m_Gadget && (pDoc->tick() % 10) < 6 )
			renderGlow( context );
	}
}
开发者ID:BlackYoup,项目名称:darkspace,代码行数:89,代码来源:ButtonGadget.cpp


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