mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
Merge pull request #214 from leMaik/context-linedashoffset
add lineDashOffset support to context
This commit is contained in:
commit
1fb5616501
@ -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());
|
||||
|
15
src/Shape.js
15
src/Shape.js
@ -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');
|
||||
|
||||
/**
|
||||
|
@ -44,6 +44,7 @@ suite('Context', function() {
|
||||
'shadowOffsetX',
|
||||
'shadowOffsetY',
|
||||
'lineCap',
|
||||
'lineDashOffset',
|
||||
'lineJoin',
|
||||
'lineWidth',
|
||||
'miterLimit',
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user