Merge pull request #5863 from fredj/stroke_pattern
Allow CanvasPattern or CanvasGradient as stroke style
This commit is contained in:
@@ -6,7 +6,6 @@ goog.provide('ol.render.canvas.Immediate');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
@@ -841,7 +840,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, st
|
||||
strokeStyleWidth : ol.render.canvas.defaultLineWidth),
|
||||
miterLimit: strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
|
||||
strokeStyle: ol.color.asString(strokeStyleColor ?
|
||||
strokeStyle: ol.colorlike.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : ol.render.canvas.defaultStrokeStyle)
|
||||
};
|
||||
}
|
||||
@@ -921,7 +920,7 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth,
|
||||
miterLimit: textStrokeStyleMiterLimit !== undefined ?
|
||||
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
|
||||
strokeStyle: ol.color.asString(textStrokeStyleColor ?
|
||||
strokeStyle: ol.colorlike.asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ goog.provide('ol.render.canvas.LineStringReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
@@ -30,14 +30,14 @@ ol.render.canvas.LineStringReplay = function(tolerance, maxExtent, resolution, o
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {{currentStrokeStyle: (string|undefined),
|
||||
* @type {{currentStrokeStyle: (ol.ColorLike|undefined),
|
||||
* currentLineCap: (string|undefined),
|
||||
* currentLineDash: Array.<number>,
|
||||
* currentLineJoin: (string|undefined),
|
||||
* currentLineWidth: (number|undefined),
|
||||
* currentMiterLimit: (number|undefined),
|
||||
* lastStroke: number,
|
||||
* strokeStyle: (string|undefined),
|
||||
* strokeStyle: (ol.ColorLike|undefined),
|
||||
* lineCap: (string|undefined),
|
||||
* lineDash: Array.<number>,
|
||||
* lineJoin: (string|undefined),
|
||||
@@ -223,7 +223,7 @@ ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle = function(fillSt
|
||||
ol.DEBUG && console.assert(!fillStyle, 'fillStyle should be null');
|
||||
ol.DEBUG && console.assert(strokeStyle, 'strokeStyle should not be null');
|
||||
var strokeStyleColor = strokeStyle.getColor();
|
||||
this.state_.strokeStyle = ol.color.asString(strokeStyleColor ?
|
||||
this.state_.strokeStyle = ol.colorlike.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
||||
|
||||
@@ -32,14 +32,14 @@ ol.render.canvas.PolygonReplay = function(tolerance, maxExtent, resolution, over
|
||||
/**
|
||||
* @private
|
||||
* @type {{currentFillStyle: (ol.ColorLike|undefined),
|
||||
* currentStrokeStyle: (string|undefined),
|
||||
* currentStrokeStyle: (ol.ColorLike|undefined),
|
||||
* currentLineCap: (string|undefined),
|
||||
* currentLineDash: Array.<number>,
|
||||
* currentLineJoin: (string|undefined),
|
||||
* currentLineWidth: (number|undefined),
|
||||
* currentMiterLimit: (number|undefined),
|
||||
* fillStyle: (ol.ColorLike|undefined),
|
||||
* strokeStyle: (string|undefined),
|
||||
* strokeStyle: (ol.ColorLike|undefined),
|
||||
* lineCap: (string|undefined),
|
||||
* lineDash: Array.<number>,
|
||||
* lineJoin: (string|undefined),
|
||||
@@ -296,7 +296,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle
|
||||
}
|
||||
if (strokeStyle) {
|
||||
var strokeStyleColor = strokeStyle.getColor();
|
||||
state.strokeStyle = ol.color.asString(strokeStyleColor ?
|
||||
state.strokeStyle = ol.colorlike.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||
state.lineCap = strokeStyleLineCap !== undefined ?
|
||||
|
||||
@@ -476,8 +476,8 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.SET_STROKE_STYLE:
|
||||
ol.DEBUG && console.assert(typeof instruction[1] === 'string',
|
||||
'2nd instruction should be a string');
|
||||
ol.DEBUG && console.assert(ol.colorlike.isColorLike(instruction[1]),
|
||||
'2nd instruction should be a string, CanvasPattern, or CanvasGradient');
|
||||
ol.DEBUG && console.assert(typeof instruction[2] === 'number',
|
||||
'3rd instruction should be a number');
|
||||
ol.DEBUG && console.assert(typeof instruction[3] === 'string',
|
||||
@@ -495,7 +495,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
context.stroke();
|
||||
pendingStroke = 0;
|
||||
}
|
||||
context.strokeStyle = /** @type {string} */ (instruction[1]);
|
||||
context.strokeStyle = /** @type {ol.ColorLike} */ (instruction[1]);
|
||||
context.lineWidth = usePixelRatio ? lineWidth * pixelRatio : lineWidth;
|
||||
context.lineCap = /** @type {string} */ (instruction[3]);
|
||||
context.lineJoin = /** @type {string} */ (instruction[4]);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.render.canvas.TextReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
@@ -267,7 +266,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
|
||||
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth;
|
||||
var miterLimit = textStrokeStyleMiterLimit !== undefined ?
|
||||
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
|
||||
var strokeStyle = ol.color.asString(textStrokeStyleColor ?
|
||||
var strokeStyle = ol.colorlike.asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||
if (!this.textStrokeState_) {
|
||||
this.textStrokeState_ = {
|
||||
|
||||
Reference in New Issue
Block a user