Merge pull request #3254 from fredj/regular-stroke
Use lineCap, lineJoin and miterLimit stroke properties in RegularShape
This commit is contained in:
@@ -278,8 +278,15 @@ ol.style.RegularShape.prototype.unlistenImageChange = goog.nullFunction;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{strokeStyle: (string|undefined), strokeWidth: number,
|
* @typedef {{
|
||||||
* size: number, lineDash: Array.<number>}}
|
* strokeStyle: (string|undefined),
|
||||||
|
* strokeWidth: number,
|
||||||
|
* size: number,
|
||||||
|
* lineCap: string,
|
||||||
|
* lineDash: Array.<number>,
|
||||||
|
* lineJoin: string,
|
||||||
|
* miterLimit: number
|
||||||
|
* }}
|
||||||
*/
|
*/
|
||||||
ol.style.RegularShape.RenderOptions;
|
ol.style.RegularShape.RenderOptions;
|
||||||
|
|
||||||
@@ -290,6 +297,9 @@ ol.style.RegularShape.RenderOptions;
|
|||||||
*/
|
*/
|
||||||
ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
||||||
var imageSize;
|
var imageSize;
|
||||||
|
var lineCap = '';
|
||||||
|
var lineJoin = '';
|
||||||
|
var miterLimit = 0;
|
||||||
var lineDash = null;
|
var lineDash = null;
|
||||||
var strokeStyle;
|
var strokeStyle;
|
||||||
var strokeWidth = 0;
|
var strokeWidth = 0;
|
||||||
@@ -304,6 +314,18 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
if (!ol.has.CANVAS_LINE_DASH) {
|
if (!ol.has.CANVAS_LINE_DASH) {
|
||||||
lineDash = null;
|
lineDash = null;
|
||||||
}
|
}
|
||||||
|
lineJoin = this.stroke_.getLineJoin();
|
||||||
|
if (!goog.isDef(lineJoin)) {
|
||||||
|
lineJoin = ol.render.canvas.defaultLineJoin;
|
||||||
|
}
|
||||||
|
lineCap = this.stroke_.getLineCap();
|
||||||
|
if (!goog.isDef(lineCap)) {
|
||||||
|
lineCap = ol.render.canvas.defaultLineCap;
|
||||||
|
}
|
||||||
|
miterLimit = this.stroke_.getMiterLimit();
|
||||||
|
if (!goog.isDef(miterLimit)) {
|
||||||
|
miterLimit = ol.render.canvas.defaultMiterLimit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var size = 2 * (this.radius_ + strokeWidth) + 1;
|
var size = 2 * (this.radius_ + strokeWidth) + 1;
|
||||||
@@ -313,7 +335,10 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
strokeStyle: strokeStyle,
|
strokeStyle: strokeStyle,
|
||||||
strokeWidth: strokeWidth,
|
strokeWidth: strokeWidth,
|
||||||
size: size,
|
size: size,
|
||||||
lineDash: lineDash
|
lineCap: lineCap,
|
||||||
|
lineDash: lineDash,
|
||||||
|
lineJoin: lineJoin,
|
||||||
|
miterLimit: miterLimit
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!goog.isDef(atlasManager)) {
|
if (!goog.isDef(atlasManager)) {
|
||||||
@@ -373,7 +398,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {ol.style.Circle.RenderOptions} renderOptions
|
* @param {ol.style.RegularShape.RenderOptions} renderOptions
|
||||||
* @param {CanvasRenderingContext2D} context
|
* @param {CanvasRenderingContext2D} context
|
||||||
* @param {number} x The origin for the symbol (x).
|
* @param {number} x The origin for the symbol (x).
|
||||||
* @param {number} y The origin for the symbol (y).
|
* @param {number} y The origin for the symbol (y).
|
||||||
@@ -407,6 +432,9 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
|
|||||||
if (!goog.isNull(renderOptions.lineDash)) {
|
if (!goog.isNull(renderOptions.lineDash)) {
|
||||||
context.setLineDash(renderOptions.lineDash);
|
context.setLineDash(renderOptions.lineDash);
|
||||||
}
|
}
|
||||||
|
context.lineCap = renderOptions.lineCap;
|
||||||
|
context.lineJoin = renderOptions.lineJoin;
|
||||||
|
context.miterLimit = renderOptions.miterLimit;
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
context.closePath();
|
context.closePath();
|
||||||
|
|||||||
Reference in New Issue
Block a user