Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
scale dashes by line-gap-width if present
Browse files Browse the repository at this point in the history
mapbox/mapbox-gl-js#860 (comment)

js: a5fb9f9fb5c7ea056b6ec228e0b398815cc0d356
  • Loading branch information
ansis committed Jan 16, 2015
1 parent 07e2396 commit 4791bac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/mbgl/style/style_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,16 @@ void StyleLayer::applyStyleProperties<LineProperties>(const float z, const times
applyStyleProperty(PropertyKey::LineDashArray, line.dash_array, z, now);
applyStyleProperty(PropertyKey::LineImage, line.image, z, now);

// for scaling dasharrays
applyStyleProperty(PropertyKey::LineWidth, line.dash_line_width, std::floor(z), now + 10000);
// scale dash width by line-gap-width if present
applyStyleProperty(PropertyKey::LineGapWidth, line.dash_line_width, std::floor(z), now + 10000);
if (line.dash_line_width <= 0) {
// otherwise scale by line-width
applyStyleProperty(PropertyKey::LineWidth, line.dash_line_width, std::floor(z), now + 10000);
if (line.dash_line_width <= 0) {
// otherwise scale by default line-width value
line.dash_line_width = line.width;
}
}
}

template <>
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/style/style_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct LineProperties {
float gap_width = 0;
float blur = 0;
std::vector<float> dash_array;
float dash_line_width = 1;
float dash_line_width = 0;
std::string image;

inline bool isVisible() const {
Expand Down

0 comments on commit 4791bac

Please sign in to comment.