Merge pull request #214 from leMaik/context-linedashoffset

add lineDashOffset support to context
This commit is contained in:
Anton Lavrenov 2017-03-20 06:49:01 -05:00 committed by GitHub
commit 1fb5616501
4 changed files with 19 additions and 0 deletions

View File

@ -51,6 +51,7 @@
'shadowOffsetX',
'shadowOffsetY',
'lineCap',
'lineDashOffset',
'lineJoin',
'lineWidth',
'miterLimit',
@ -599,6 +600,7 @@
this._applyLineCap(shape);
if (dash && shape.dashEnabled()) {
this.setLineDash(dash);
this.setAttr('lineDashOffset', shape.dashOffset());
}
this.setAttr('lineWidth', shape.strokeWidth());

View File

@ -713,6 +713,21 @@
* line.dash([10, 20, 0.001, 20]);
*/
Konva.Factory.addGetterSetter(Konva.Shape, 'dashOffset', 0);
/**
* get/set dash offset for stroke.
* @name dash
* @method
* @memberof Konva.Shape.prototype
* @param {Number} dash offset
* @returns {Number}
* @example
* // apply dashed stroke that is 10px long and 5 pixels apart with an offset of 5px
* line.dash([10, 5]);
* line.dashOffset(5);
*/
Konva.Factory.addGetterSetter(Konva.Shape, 'shadowColor');
/**

View File

@ -44,6 +44,7 @@ suite('Context', function() {
'shadowOffsetX',
'shadowOffsetY',
'lineCap',
'lineDashOffset',
'lineJoin',
'lineWidth',
'miterLimit',

View File

@ -896,6 +896,7 @@ suite('Shape', function() {
assert.equal(shape.strokeEnabled(), true);
assert.equal(shape.shadowEnabled(), true);
assert.equal(shape.dashEnabled(), true);
assert.equal(shape.dashOffset(), 0);
assert.equal(shape.strokeScaleEnabled(), true);
assert.equal(shape.fillPriority(), 'color');
assert.equal(shape.fillPatternOffsetX(), 0);