@@ -735,6 +735,7 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
|
|||||||
context.lineCap = strokeState.lineCap;
|
context.lineCap = strokeState.lineCap;
|
||||||
if (ol.has.CANVAS_LINE_DASH) {
|
if (ol.has.CANVAS_LINE_DASH) {
|
||||||
context.setLineDash(strokeState.lineDash);
|
context.setLineDash(strokeState.lineDash);
|
||||||
|
context.lineDashOffset = strokeState.lineDashOffset;
|
||||||
}
|
}
|
||||||
context.lineJoin = strokeState.lineJoin;
|
context.lineJoin = strokeState.lineJoin;
|
||||||
context.lineWidth = strokeState.lineWidth;
|
context.lineWidth = strokeState.lineWidth;
|
||||||
@@ -743,6 +744,7 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
|
|||||||
this.contextStrokeState_ = {
|
this.contextStrokeState_ = {
|
||||||
lineCap: strokeState.lineCap,
|
lineCap: strokeState.lineCap,
|
||||||
lineDash: strokeState.lineDash,
|
lineDash: strokeState.lineDash,
|
||||||
|
lineDashOffset: strokeState.lineDashOffset,
|
||||||
lineJoin: strokeState.lineJoin,
|
lineJoin: strokeState.lineJoin,
|
||||||
lineWidth: strokeState.lineWidth,
|
lineWidth: strokeState.lineWidth,
|
||||||
miterLimit: strokeState.miterLimit,
|
miterLimit: strokeState.miterLimit,
|
||||||
@@ -757,6 +759,10 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
|
|||||||
contextStrokeState.lineDash, strokeState.lineDash)) {
|
contextStrokeState.lineDash, strokeState.lineDash)) {
|
||||||
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
|
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
|
||||||
}
|
}
|
||||||
|
if (contextStrokeState.lineDashOffset != strokeState.lineDashOffset) {
|
||||||
|
contextStrokeState.lineDashOffset = context.lineDashOffset =
|
||||||
|
strokeState.lineDashOffset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (contextStrokeState.lineJoin != strokeState.lineJoin) {
|
if (contextStrokeState.lineJoin != strokeState.lineJoin) {
|
||||||
contextStrokeState.lineJoin = context.lineJoin = strokeState.lineJoin;
|
contextStrokeState.lineJoin = context.lineJoin = strokeState.lineJoin;
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
var lineJoin = '';
|
var lineJoin = '';
|
||||||
var miterLimit = 0;
|
var miterLimit = 0;
|
||||||
var lineDash = null;
|
var lineDash = null;
|
||||||
|
var lineDashOffset = 0;
|
||||||
var strokeStyle;
|
var strokeStyle;
|
||||||
var strokeWidth = 0;
|
var strokeWidth = 0;
|
||||||
|
|
||||||
@@ -331,8 +332,10 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
strokeWidth = ol.render.canvas.defaultLineWidth;
|
strokeWidth = ol.render.canvas.defaultLineWidth;
|
||||||
}
|
}
|
||||||
lineDash = this.stroke_.getLineDash();
|
lineDash = this.stroke_.getLineDash();
|
||||||
|
lineDashOffset = this.stroke_.getLineDashOffset();
|
||||||
if (!ol.has.CANVAS_LINE_DASH) {
|
if (!ol.has.CANVAS_LINE_DASH) {
|
||||||
lineDash = null;
|
lineDash = null;
|
||||||
|
lineDashOffset = 0;
|
||||||
}
|
}
|
||||||
lineJoin = this.stroke_.getLineJoin();
|
lineJoin = this.stroke_.getLineJoin();
|
||||||
if (lineJoin === undefined) {
|
if (lineJoin === undefined) {
|
||||||
@@ -357,6 +360,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
size: size,
|
size: size,
|
||||||
lineCap: lineCap,
|
lineCap: lineCap,
|
||||||
lineDash: lineDash,
|
lineDash: lineDash,
|
||||||
|
lineDashOffset: lineDashOffset,
|
||||||
lineJoin: lineJoin,
|
lineJoin: lineJoin,
|
||||||
miterLimit: miterLimit
|
miterLimit: miterLimit
|
||||||
};
|
};
|
||||||
@@ -460,6 +464,7 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
|
|||||||
context.lineWidth = renderOptions.strokeWidth;
|
context.lineWidth = renderOptions.strokeWidth;
|
||||||
if (renderOptions.lineDash) {
|
if (renderOptions.lineDash) {
|
||||||
context.setLineDash(renderOptions.lineDash);
|
context.setLineDash(renderOptions.lineDash);
|
||||||
|
context.lineDashOffset = renderOptions.lineDashOffset;
|
||||||
}
|
}
|
||||||
context.lineCap = renderOptions.lineCap;
|
context.lineCap = renderOptions.lineCap;
|
||||||
context.lineJoin = renderOptions.lineJoin;
|
context.lineJoin = renderOptions.lineJoin;
|
||||||
@@ -533,6 +538,7 @@ ol.style.RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions
|
|||||||
context.lineWidth = renderOptions.strokeWidth;
|
context.lineWidth = renderOptions.strokeWidth;
|
||||||
if (renderOptions.lineDash) {
|
if (renderOptions.lineDash) {
|
||||||
context.setLineDash(renderOptions.lineDash);
|
context.setLineDash(renderOptions.lineDash);
|
||||||
|
context.lineDashOffset = renderOptions.lineDashOffset;
|
||||||
}
|
}
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ ol.CanvasFunctionType;
|
|||||||
/**
|
/**
|
||||||
* @typedef {{lineCap: string,
|
* @typedef {{lineCap: string,
|
||||||
* lineDash: Array.<number>,
|
* lineDash: Array.<number>,
|
||||||
|
* lineDashOffset: number,
|
||||||
* lineJoin: string,
|
* lineJoin: string,
|
||||||
* lineWidth: number,
|
* lineWidth: number,
|
||||||
* miterLimit: number,
|
* miterLimit: number,
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 396 B |
Binary file not shown.
|
After Width: | Height: | Size: 403 B |
@@ -135,6 +135,49 @@ describe('ol.render', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('supports lineDash styles', function(done) {
|
||||||
|
var vectorContext = ol.render.toContext(context, {size: [100, 100]});
|
||||||
|
|
||||||
|
var style = new ol.style.Style({
|
||||||
|
stroke: new ol.style.Stroke({
|
||||||
|
lineDash: [10, 5]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
vectorContext.setStyle(style);
|
||||||
|
|
||||||
|
vectorContext.drawGeometry(new ol.geom.Polygon([
|
||||||
|
[[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]],
|
||||||
|
[[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]]
|
||||||
|
]));
|
||||||
|
|
||||||
|
resembleCanvas(context.canvas,
|
||||||
|
'spec/ol/expected/render-polygon-linedash.png', IMAGE_TOLERANCE, done);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports lineDashOffset', function(done) {
|
||||||
|
var vectorContext = ol.render.toContext(context, {size: [100, 100]});
|
||||||
|
|
||||||
|
var style = new ol.style.Style({
|
||||||
|
stroke: new ol.style.Stroke({
|
||||||
|
lineDash: [10, 5],
|
||||||
|
lineDashOffset: 5
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
vectorContext.setStyle(style);
|
||||||
|
|
||||||
|
vectorContext.drawGeometry(new ol.geom.Polygon([
|
||||||
|
[[25, 25], [75, 25], [75, 75], [25, 75], [25, 25]],
|
||||||
|
[[40, 40], [40, 60], [60, 60], [60, 40], [40, 40]]
|
||||||
|
]));
|
||||||
|
|
||||||
|
resembleCanvas(context.canvas,
|
||||||
|
'spec/ol/expected/render-polygon-linedashoffset.png', IMAGE_TOLERANCE, done);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 819 B |
Binary file not shown.
|
After Width: | Height: | Size: 831 B |
@@ -119,6 +119,23 @@ describe('ol.rendering.style.RegularShape', function() {
|
|||||||
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas.png', 9.4, done);
|
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas.png', 9.4, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('supports lineDash', function(done) {
|
||||||
|
map = createMap('canvas');
|
||||||
|
createFeatures(new ol.style.Stroke({
|
||||||
|
lineDash: [10, 5]
|
||||||
|
}));
|
||||||
|
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas-linedash.png', 5, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports lineDashOffset', function(done) {
|
||||||
|
map = createMap('canvas');
|
||||||
|
createFeatures(new ol.style.Stroke({
|
||||||
|
lineDash: [10, 5],
|
||||||
|
lineDashOffset: 5
|
||||||
|
}));
|
||||||
|
expectResemble(map, 'spec/ol/style/expected/regularshape-canvas-linedashoffset.png', 5, done);
|
||||||
|
});
|
||||||
|
|
||||||
it('tests the WebGL renderer', function(done) {
|
it('tests the WebGL renderer', function(done) {
|
||||||
assertWebGL();
|
assertWebGL();
|
||||||
map = createMap('webgl');
|
map = createMap('webgl');
|
||||||
|
|||||||
Reference in New Issue
Block a user