fix sprite atlas padding and icon centering
Pad each icon with one pixel on the bottom and right sides. On top of this, extra padding is added to round the widths and heights to multiples of four. This then fixes the positions of the bottom and right vertices to correctly center the icon's box around the center of the icon, not the center of the padded icon. js: 32ca4007699d1d21ab25bb38588b151510194030 fixes https://github.com/mapbox/mapbox-gl-js/issues/947
This commit is contained in:
@@ -130,15 +130,13 @@ GlyphBox getMergedBoxes(const GlyphBoxes &glyphs, const Anchor &anchor) {
|
||||
|
||||
Placement Placement::getIcon(Anchor &anchor, const Rect<uint16_t> &image, float boxScale,
|
||||
const std::vector<Coordinate> &line, const StyleBucketSymbol &props) {
|
||||
const float x = image.w / 2.0f; // No need to divide by image.pixelRatio here?
|
||||
const float y = image.h / 2.0f; // image.pixelRatio;
|
||||
|
||||
const float dx = props.icon.offset.x;
|
||||
const float dy = props.icon.offset.y;
|
||||
float x1 = (dx - x);
|
||||
float x2 = (dx + x);
|
||||
float y1 = (dy - y);
|
||||
float y2 = (dy + y);
|
||||
float x1 = dx - image.originalW / 2.0f;
|
||||
float x2 = x1 + image.w;
|
||||
float y1 = dy - image.originalH / 2.0f;
|
||||
float y2 = y1 + image.h;
|
||||
|
||||
vec2<float> tl{x1, y1};
|
||||
vec2<float> tr{x2, y1};
|
||||
|
||||
Reference in New Issue
Block a user