Color 2 D2D1_COLOR_F

This commit is contained in:
Nomango 2018-07-29 02:24:34 +08:00
parent 180d2067fa
commit 62a34b9ba2
6 changed files with 14 additions and 14 deletions

View File

@ -177,7 +177,7 @@ e2d::Color e2d::Renderer::getBackgroundColor()
void e2d::Renderer::setBackgroundColor(Color color)
{
_clearColor = color.toD2DColorF();
_clearColor = (D2D1_COLOR_F)color;
}
ID2D1HwndRenderTarget * e2d::Renderer::getRenderTarget()

View File

@ -84,7 +84,7 @@ void e2d::Collider::render()
// 获取纯色画刷
ID2D1SolidColorBrush * brush = renderer->getSolidColorBrush();
// 设置画刷颜色和透明度
brush->SetColor(_color.toD2DColorF());
brush->SetColor((D2D1_COLOR_F)_color);
brush->SetOpacity(1.f);
// 绘制几何碰撞体
renderer->getRenderTarget()->DrawGeometry(_geometry, brush, 1.5f);

View File

@ -42,6 +42,11 @@ e2d::Color::Color(UINT rgb, float 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)
{
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;
a = alpha;
}
D2D1_COLOR_F e2d::Color::toD2DColorF() const
{
return D2D1::ColorF(r, g, b, a);
}

View File

@ -22,24 +22,24 @@ void e2d::Shape::onRender() const
{
case Style::Fill:
{
pBrush->SetColor(_fillColor.toD2DColorF());
pBrush->SetColor((D2D1_COLOR_F)_fillColor);
this->_renderFill();
pBrush->SetColor(_lineColor.toD2DColorF());
pBrush->SetColor((D2D1_COLOR_F)_lineColor);
this->_renderLine();
break;
}
case Style::Round:
{
pBrush->SetColor(_lineColor.toD2DColorF());
pBrush->SetColor((D2D1_COLOR_F)_lineColor);
this->_renderLine();
break;
}
case Style::Solid:
{
pBrush->SetColor(_fillColor.toD2DColorF());
pBrush->SetColor((D2D1_COLOR_F)_fillColor);
this->_renderFill();
break;
}

View File

@ -299,9 +299,9 @@ void e2d::Text::onRender() const
// 获取文本渲染器
auto pTextRenderer = renderer->getTextRenderer();
pTextRenderer->SetTextStyle(
_style.color.toD2DColorF(),
(D2D1_COLOR_F)_style.color,
_style.hasOutline,
_style.outlineColor.toD2DColorF(),
(D2D1_COLOR_F)_style.outlineColor,
_style.outlineWidth,
D2D1_LINE_JOIN(_style.outlineJoin)
);

View File

@ -312,7 +312,7 @@ public:
float alpha
);
D2D1_COLOR_F toD2DColorF() const;
E2D_OP_EXPLICIT operator D2D1_COLOR_F() const;
public:
enum Value : UINT