forked from organicmaps/organicmaps
CircleRule rendering. colors should be fixed at classificator.
This commit is contained in:
parent
8df85096ba
commit
b8eb699ad3
8 changed files with 39 additions and 32 deletions
|
@ -85,14 +85,18 @@ void DrawerYG::drawSymbol(m2::PointD const & pt, string const & symbolName, yg::
|
|||
m_pScreen->drawSymbol(pt, m_pSkin->mapSymbol(symbolName.c_str()), pos, depth);
|
||||
}
|
||||
|
||||
void DrawerYG::drawCircle(m2::PointD const & pt, rule_ptr_t pRule, int depth)
|
||||
void DrawerYG::drawCircle(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth)
|
||||
{
|
||||
uint32_t id = pRule->GetID();
|
||||
if (id == drule::BaseRule::empty_id)
|
||||
{
|
||||
yg::CircleInfo info(pRule->GetRadius(),
|
||||
double radius = min(max(pRule->GetRadius(), 3.0), 6.0) * m_visualScale;
|
||||
|
||||
yg::CircleInfo info(radius,
|
||||
yg::Color::fromXRGB(pRule->GetColor(), pRule->GetAlpha()),
|
||||
true);
|
||||
true,
|
||||
m_visualScale,
|
||||
yg::Color::fromXRGB(pRule->GetStrokeColor(), pRule->GetAlpha()));
|
||||
|
||||
id = m_pSkin->mapCircleInfo(info);
|
||||
|
||||
|
@ -105,7 +109,7 @@ void DrawerYG::drawCircle(m2::PointD const & pt, rule_ptr_t pRule, int depth)
|
|||
}
|
||||
}
|
||||
|
||||
m_pScreen->drawCircle(pt, id, depth);
|
||||
m_pScreen->drawCircle(pt, id, pos, depth);
|
||||
}
|
||||
|
||||
void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth)
|
||||
|
@ -347,7 +351,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, rule_ptr_t * rules, int * depthV
|
|||
if (isSymbol)
|
||||
drawSymbol(pInfo->m_point, pRule, yg::EPosLeft, depth);
|
||||
if (isCircle)
|
||||
drawCircle(pInfo->m_point, pRule, depth);
|
||||
drawCircle(pInfo->m_point, pRule, yg::EPosLeft, depth);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -63,7 +63,7 @@ private:
|
|||
|
||||
protected:
|
||||
void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth);
|
||||
void drawCircle(m2::PointD const & pt, rule_ptr_t pRule, int depth);
|
||||
void drawCircle(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth);
|
||||
void drawPath(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth);
|
||||
void drawPath(vector<m2::PointD> const & pts, rule_ptr_t * rules, int * depthVec, size_t count);
|
||||
void drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth);
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace yg
|
|||
unsigned radius,
|
||||
Color const & color = Color(0, 0, 0, 255),
|
||||
bool isOutlined = false,
|
||||
unsigned outlineWidth = 0,
|
||||
unsigned outlineWidth = 1,
|
||||
Color const & outlineColor = Color(255, 255, 255, 255));
|
||||
};
|
||||
|
||||
|
|
|
@ -65,23 +65,5 @@ namespace yg
|
|||
drawTrianglesList(§orPts[0], sectorPts.size(), skin()->mapColor(c), depth);
|
||||
}
|
||||
|
||||
void ShapeRenderer::drawCircle(m2::PointD const & center, uint32_t styleID, double depth)
|
||||
{
|
||||
ResourceStyle const * style(skin()->fromID(styleID));
|
||||
|
||||
m2::RectU texRect(style->m_texRect);
|
||||
texRect.Inflate(-1, -1);
|
||||
|
||||
m2::PointD pt(center - m2::PointD(texRect.SizeX() / 2, texRect.SizeY() / 2));
|
||||
pt.x = ceil(pt.x);
|
||||
pt.y = ceil(pt.y);
|
||||
|
||||
|
||||
drawTexturedPolygon(m2::PointD(0, 0), 0,
|
||||
texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(),
|
||||
pt.x, pt.y, pt.x + texRect.SizeX(), pt.y + texRect.SizeY(),
|
||||
depth,
|
||||
style->m_pageID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ namespace yg
|
|||
void drawArc(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth);
|
||||
void drawSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth);
|
||||
void fillSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth);
|
||||
|
||||
void drawCircle(m2::PointD const & center, uint32_t styleID, double depth);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ namespace yg
|
|||
if (penInfo.m_w > 2)
|
||||
{
|
||||
agg::ellipse ell;
|
||||
float r = penInfo.m_w / 2.0;
|
||||
float r = ceil(penInfo.m_w) / 2.0;
|
||||
ell.init(r + 2, r + 2, r, r, 100);
|
||||
rasterizer.add_path(ell);
|
||||
|
||||
|
@ -446,12 +446,18 @@ namespace yg
|
|||
penInfo.m_color.b,
|
||||
penInfo.m_color.a));
|
||||
|
||||
/* /// in non-transparent areas - premultiply color value with alpha and make it opaque
|
||||
/// pixels that are used to texture inner part of the line should be fully opaque
|
||||
v(2 + r - 1, 2) = penColor;
|
||||
v(2 + r , 2) = penColor;
|
||||
v(2 + r - 1, 2 + r * 2 - 1) = penColor;
|
||||
v(2 + r , 2 + r * 2 - 1) = penColor;
|
||||
|
||||
/// in non-transparent areas - premultiply color value with alpha and make it opaque
|
||||
for (size_t x = 2; x < v.width() - 2; ++x)
|
||||
for (size_t y = 2; y < v.height() - 2; ++y)
|
||||
{
|
||||
unsigned char alpha = gil::get_color(v(x, y), gil::alpha_t());
|
||||
float fAlpha = alpha / (float)TDynamicTexture::maxChannelVal;
|
||||
// float fAlpha = alpha / (float)TDynamicTexture::maxChannelVal;
|
||||
if (alpha != 0)
|
||||
{
|
||||
// gil::get_color(v(x, y), gil::red_t()) *= fAlpha;
|
||||
|
@ -462,12 +468,11 @@ namespace yg
|
|||
v(x, y) = penColor;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
gil::fill_pixels(
|
||||
gil::subimage_view(v, 1, 1, rect.SizeX() - 2, rect.SizeY() - 2),
|
||||
gil::subimage_view(v, 2, 2, rect.SizeX() - 4, rect.SizeY() - 4),
|
||||
penColor
|
||||
);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,23 @@ namespace yg
|
|||
style->m_pageID);
|
||||
}
|
||||
|
||||
void SymbolRenderer::drawCircle(m2::PointD const & pt, uint32_t styleID, EPosition pos, int depth)
|
||||
{
|
||||
ResourceStyle const * style(skin()->fromID(styleID));
|
||||
|
||||
m2::RectU texRect(style->m_texRect);
|
||||
texRect.Inflate(-1, -1);
|
||||
|
||||
m2::PointD posPt = getPosPt(pt, m2::RectD(texRect), pos);
|
||||
|
||||
drawTexturedPolygon(m2::PointD(0, 0), 0,
|
||||
texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(),
|
||||
posPt.x, posPt.y, posPt.x + texRect.SizeX(), posPt.y + texRect.SizeY(),
|
||||
depth,
|
||||
style->m_pageID);
|
||||
}
|
||||
|
||||
|
||||
void mark_intersect(bool & flag)
|
||||
{
|
||||
flag = true;
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace yg
|
|||
SymbolRenderer(base_t::Params const & params);
|
||||
|
||||
void drawSymbol(m2::PointD const & pt, uint32_t styleID, EPosition pos, int depth);
|
||||
void drawCircle(m2::PointD const & pt, uint32_t styleID, EPosition pos, int depth);
|
||||
|
||||
void setClipRect(m2::RectI const & rect);
|
||||
void endFrame();
|
||||
|
|
Loading…
Add table
Reference in a new issue