Line Dash offset

This commit is contained in:
Thomas Chandelle
2016-11-08 15:38:00 +01:00
parent fd1029600b
commit 7a4ae3a6ac
17 changed files with 150 additions and 15 deletions

View File

@@ -34,7 +34,8 @@ describe('ol.render.canvas.ReplayGroup', function() {
});
style2 = new ol.style.Style({
fill: new ol.style.Fill({color: 'white'}),
stroke: new ol.style.Stroke({color: 'black', width: 1, lineDash: [3, 6]})
stroke: new ol.style.Stroke({color: 'black', width: 1, lineDash: [3, 6],
lineDashOffset: 2})
});
fillCount = 0;
strokeCount = 0;
@@ -140,14 +141,22 @@ describe('ol.render.canvas.ReplayGroup', function() {
expect(beginPathCount).to.be(3);
});
it('applies the pixelRatio to the linedash array', function() {
var lineDash, lineDashCount = 0;
it('applies the pixelRatio to the linedash array and offset', function() {
var lineDash, lineDashCount = 0,
lineDashOffset, lineDashOffsetCount = 0;
context.setLineDash = function(lineDash_) {
lineDashCount++;
lineDash = lineDash_.slice();
};
Object.defineProperty(context, 'lineDashOffset', {
set: function(lineDashOffset_) {
lineDashOffsetCount++;
lineDashOffset = lineDashOffset_;
}
});
ol.renderer.vector.renderFeature(replay, feature1, style2, 1);
ol.renderer.vector.renderFeature(replay, feature2, style2, 1);
replay.replay(context, 2, transform, 0, {});
@@ -155,6 +164,10 @@ describe('ol.render.canvas.ReplayGroup', function() {
expect(lineDashCount).to.be(1);
expect(style2.getStroke().getLineDash()).to.eql([3, 6]);
expect(lineDash).to.eql([6, 12]);
expect(lineDashOffsetCount).to.be(1);
expect(style2.getStroke().getLineDashOffset()).to.be(2);
expect(lineDashOffset).to.be(4);
});
});

View File

@@ -19,6 +19,7 @@ describe('ol.style.Stroke', function() {
lineCap: 'square',
lineJoin: 'miter',
lineDash: [1, 2, 3],
lineDashOffset: 2,
miterLimit: 20,
width: 5
});
@@ -27,6 +28,7 @@ describe('ol.style.Stroke', function() {
expect(original.getLineCap()).to.eql(clone.getLineCap());
expect(original.getLineJoin()).to.eql(clone.getLineJoin());
expect(original.getLineDash()).to.eql(clone.getLineDash());
expect(original.getLineDashOffset()).to.eql(clone.getLineDashOffset());
expect(original.getMiterLimit()).to.eql(clone.getMiterLimit());
expect(original.getWidth()).to.eql(clone.getWidth());
});