Skip to content

Commit

Permalink
Merge pull request #980 from OpenGeoscience/polygon-stroke-fewer-styl…
Browse files Browse the repository at this point in the history
…e-calls

Make fewer style.get calls when computing polygon strokes.
  • Loading branch information
manthey authored Feb 28, 2019
2 parents 2af1d51 + 2071fd7 commit 315b653
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Change Log

## Unreleased

### Improvements
- Make fewer function calls when computing polygon strokes (#980)

## Version 0.19.1

### Features
- Polygon annotations can be drawn in the same continuous smooth manner as line annotations.
- Polygon annotations can be drawn in the same continuous smooth manner as line annotations. (#976)

### Changes
- Rename the d3 renderer to svg. d3 still works as an alias (#965)
Expand Down
18 changes: 12 additions & 6 deletions src/polygonFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,17 @@ var polygonFeature = function (arg) {
});
m_this.dependentFeatures([m_lineFeature]);
}
var polyStyle = m_this.style();
var polyStyle = m_this.style(),
strokeOpacity;
if (util.isFunction(polyStyle.stroke) || !polyStyle.stroke) {
var strokeFunc = m_this.style.get('stroke'),
strokeOpacityFunc = m_this.style.get('strokeOpacity');
strokeOpacity = function (d) {
return strokeFunc(d[2], d[3]) ? strokeOpacityFunc(d[0], d[1], d[2], d[3]) : 0;
};
} else {
strokeOpacity = linePolyStyle(polyStyle.strokeOpacity);
}
m_lineFeature.style({
antialiasing: linePolyStyle(polyStyle.antialiasing),
closed: true,
Expand All @@ -348,11 +358,7 @@ var polygonFeature = function (arg) {
strokeStyle: linePolyStyle(polyStyle.strokeStyle),
strokeColor: linePolyStyle(polyStyle.strokeColor),
strokeOffset: linePolyStyle(polyStyle.strokeOffset),
strokeOpacity: util.isFunction(polyStyle.stroke) || !polyStyle.stroke ?
function (d) {
return m_this.style.get('stroke')(d[2], d[3]) ? m_this.style.get('strokeOpacity')(d[0], d[1], d[2], d[3]) : 0;
} :
linePolyStyle(polyStyle.strokeOpacity)
strokeOpacity: strokeOpacity
});
var data = m_this.data(),
posVal = m_this.style('position');
Expand Down

0 comments on commit 315b653

Please sign in to comment.