fix shaped icon box sizes

This commit is contained in:
Ansis Brammanis
2015-05-28 19:15:56 -04:00
parent 4cd95a97c6
commit fd19eb7905
2 changed files with 11 additions and 7 deletions

View File

@@ -13,10 +13,15 @@ SymbolQuads getIconQuads(Anchor &anchor, const PositionedIcon &shapedIcon,
const std::vector<Coordinate> &line, const StyleLayoutSymbol &layout,
const bool alongLine) {
vec2<float> tl{shapedIcon.left, shapedIcon.top};
vec2<float> tr{shapedIcon.right, shapedIcon.top};
vec2<float> br{shapedIcon.right, shapedIcon.bottom};
vec2<float> bl{shapedIcon.left, shapedIcon.bottom};
const float border = 1.0;
auto left = shapedIcon.left - border;
auto right = left + shapedIcon.image.w;
auto top = shapedIcon.top - border;
auto bottom = top + shapedIcon.image.h;
vec2<float> tl{left, top};
vec2<float> tr{right, top};
vec2<float> br{right, bottom};
vec2<float> bl{left, bottom};
float angle = layout.icon.rotate * M_PI / 180.0f;

View File

@@ -6,11 +6,10 @@ namespace mbgl {
PositionedIcon shapeIcon(const Rect<uint16_t> &image, const StyleLayoutSymbol &layout) {
float dx = layout.icon.offset[0];
float dy = layout.icon.offset[1];
// TODO, this is image.image.width in -js
float x1 = dx - image.originalW / 2.0f;
float x2 = x1 + image.w;
float x2 = x1 + image.originalW;
float y1 = dy - image.originalH / 2.0f;
float y2 = y1 + image.h;
float y2 = y1 + image.originalH;
return PositionedIcon(image, y1, y2, x1, x2);
}