Color 2 D2D1_COLOR_F
This commit is contained in:
		
							parent
							
								
									180d2067fa
								
							
						
					
					
						commit
						62a34b9ba2
					
				|  | @ -177,7 +177,7 @@ e2d::Color e2d::Renderer::getBackgroundColor() | ||||||
| 
 | 
 | ||||||
| void e2d::Renderer::setBackgroundColor(Color color) | void e2d::Renderer::setBackgroundColor(Color color) | ||||||
| { | { | ||||||
| 	_clearColor = color.toD2DColorF(); | 	_clearColor = (D2D1_COLOR_F)color; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ID2D1HwndRenderTarget * e2d::Renderer::getRenderTarget() | ID2D1HwndRenderTarget * e2d::Renderer::getRenderTarget() | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ void e2d::Collider::render() | ||||||
| 		// 获取纯色画刷
 | 		// 获取纯色画刷
 | ||||||
| 		ID2D1SolidColorBrush * brush = renderer->getSolidColorBrush(); | 		ID2D1SolidColorBrush * brush = renderer->getSolidColorBrush(); | ||||||
| 		// 设置画刷颜色和透明度
 | 		// 设置画刷颜色和透明度
 | ||||||
| 		brush->SetColor(_color.toD2DColorF()); | 		brush->SetColor((D2D1_COLOR_F)_color); | ||||||
| 		brush->SetOpacity(1.f); | 		brush->SetOpacity(1.f); | ||||||
| 		// 绘制几何碰撞体
 | 		// 绘制几何碰撞体
 | ||||||
| 		renderer->getRenderTarget()->DrawGeometry(_geometry, brush, 1.5f); | 		renderer->getRenderTarget()->DrawGeometry(_geometry, brush, 1.5f); | ||||||
|  |  | ||||||
|  | @ -42,6 +42,11 @@ e2d::Color::Color(UINT rgb, float alpha) | ||||||
| 	_init(rgb, alpha); | 	_init(rgb, alpha); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | e2d::Color::operator D2D1_COLOR_F() const | ||||||
|  | { | ||||||
|  | 	return D2D1::ColorF(r, g, b, a); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void e2d::Color::_init(UINT rgb, float alpha) | void e2d::Color::_init(UINT rgb, float alpha) | ||||||
| { | { | ||||||
| 	r = ((rgb & sc_redMask) >> sc_redShift) / 255.f; | 	r = ((rgb & sc_redMask) >> sc_redShift) / 255.f; | ||||||
|  | @ -49,8 +54,3 @@ void e2d::Color::_init(UINT rgb, float alpha) | ||||||
| 	b = ((rgb & sc_blueMask) >> sc_blueShift) / 255.f; | 	b = ((rgb & sc_blueMask) >> sc_blueShift) / 255.f; | ||||||
| 	a = alpha; | 	a = alpha; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| D2D1_COLOR_F e2d::Color::toD2DColorF() const |  | ||||||
| { |  | ||||||
| 	return D2D1::ColorF(r, g, b, a); |  | ||||||
| } |  | ||||||
|  |  | ||||||
|  | @ -22,24 +22,24 @@ void e2d::Shape::onRender() const | ||||||
| 	{ | 	{ | ||||||
| 	case Style::Fill: | 	case Style::Fill: | ||||||
| 	{ | 	{ | ||||||
| 		pBrush->SetColor(_fillColor.toD2DColorF()); | 		pBrush->SetColor((D2D1_COLOR_F)_fillColor); | ||||||
| 		this->_renderFill(); | 		this->_renderFill(); | ||||||
| 
 | 
 | ||||||
| 		pBrush->SetColor(_lineColor.toD2DColorF()); | 		pBrush->SetColor((D2D1_COLOR_F)_lineColor); | ||||||
| 		this->_renderLine(); | 		this->_renderLine(); | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	case Style::Round: | 	case Style::Round: | ||||||
| 	{ | 	{ | ||||||
| 		pBrush->SetColor(_lineColor.toD2DColorF()); | 		pBrush->SetColor((D2D1_COLOR_F)_lineColor); | ||||||
| 		this->_renderLine(); | 		this->_renderLine(); | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	case Style::Solid: | 	case Style::Solid: | ||||||
| 	{ | 	{ | ||||||
| 		pBrush->SetColor(_fillColor.toD2DColorF()); | 		pBrush->SetColor((D2D1_COLOR_F)_fillColor); | ||||||
| 		this->_renderFill(); | 		this->_renderFill(); | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -299,9 +299,9 @@ void e2d::Text::onRender() const | ||||||
| 		// 获取文本渲染器
 | 		// 获取文本渲染器
 | ||||||
| 		auto pTextRenderer = renderer->getTextRenderer(); | 		auto pTextRenderer = renderer->getTextRenderer(); | ||||||
| 		pTextRenderer->SetTextStyle( | 		pTextRenderer->SetTextStyle( | ||||||
| 			_style.color.toD2DColorF(), | 			(D2D1_COLOR_F)_style.color, | ||||||
| 			_style.hasOutline, | 			_style.hasOutline, | ||||||
| 			_style.outlineColor.toD2DColorF(), | 			(D2D1_COLOR_F)_style.outlineColor, | ||||||
| 			_style.outlineWidth, | 			_style.outlineWidth, | ||||||
| 			D2D1_LINE_JOIN(_style.outlineJoin) | 			D2D1_LINE_JOIN(_style.outlineJoin) | ||||||
| 		); | 		); | ||||||
|  |  | ||||||
|  | @ -312,7 +312,7 @@ public: | ||||||
| 		float alpha | 		float alpha | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	D2D1_COLOR_F toD2DColorF() const; | 	E2D_OP_EXPLICIT operator D2D1_COLOR_F() const; | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
| 	enum Value : UINT | 	enum Value : UINT | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue