Use CanvasLineCap type instead of string

This commit is contained in:
Frederic Junod
2019-07-05 11:11:35 +02:00
parent 7a8a0c18ae
commit ad51c7c08f
5 changed files with 14 additions and 14 deletions
+3 -3
View File
@@ -30,7 +30,7 @@ import ImageStyle from './Image.js';
* @property {import("../colorlike.js").ColorLike} [strokeStyle]
* @property {number} strokeWidth
* @property {number} size
* @property {string} lineCap
* @property {CanvasLineCap} lineCap
* @property {Array<number>} lineDash
* @property {number} lineDashOffset
* @property {CanvasLineJoin} lineJoin
@@ -302,7 +302,7 @@ class RegularShape extends ImageStyle {
* @protected
*/
render() {
let lineCap = '';
let lineCap = defaultLineCap;
let lineJoin = defaultLineJoin;
let miterLimit = 0;
let lineDash = null;
@@ -417,7 +417,7 @@ class RegularShape extends ImageStyle {
context.setLineDash(renderOptions.lineDash);
context.lineDashOffset = renderOptions.lineDashOffset;
}
context.lineCap = /** @type {CanvasLineCap} */ (renderOptions.lineCap);
context.lineCap = renderOptions.lineCap;
context.lineJoin = renderOptions.lineJoin;
context.miterLimit = renderOptions.miterLimit;
context.stroke();
+4 -4
View File
@@ -8,7 +8,7 @@
* @property {import("../color.js").Color|import("../colorlike.js").ColorLike} [color] A color, gradient or pattern.
* See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.
* Default null; if null, the Canvas/renderer default black will be used.
* @property {string} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.
* @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.
* @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.
* @property {Array<number>} [lineDash] Line dash pattern. Default is `undefined` (no dash).
* Please note that Internet Explorer 10 and lower do not support the `setLineDash` method on
@@ -43,7 +43,7 @@ class Stroke {
/**
* @private
* @type {string|undefined}
* @type {CanvasLineCap|undefined}
*/
this.lineCap_ = options.lineCap;
@@ -107,7 +107,7 @@ class Stroke {
/**
* Get the line cap type for the stroke.
* @return {string|undefined} Line cap.
* @return {CanvasLineCap|undefined} Line cap.
* @api
*/
getLineCap() {
@@ -172,7 +172,7 @@ class Stroke {
/**
* Set the line cap.
*
* @param {string|undefined} lineCap Line cap.
* @param {CanvasLineCap|undefined} lineCap Line cap.
* @api
*/
setLineCap(lineCap) {