mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
moved dashArray attr to Shape level and hooked into native setLineDash method now that it's in the spec. This enables dashed lines for any type of stroke, not just straight lines
This commit is contained in:
@@ -183,9 +183,18 @@
|
||||
}
|
||||
},
|
||||
_stroke: function(shape, skipShadow) {
|
||||
var context = this.context, stroke = shape.getStroke(), strokeWidth = shape.getStrokeWidth(), shadow = shape.getShadow();
|
||||
var context = this.context, stroke = shape.getStroke(), strokeWidth = shape.getStrokeWidth(), shadow = shape.getShadow(), dashArray = shape.getDashArray();
|
||||
if(stroke || strokeWidth) {
|
||||
context.save();
|
||||
this._applyLineCap(shape);
|
||||
if(dashArray) {
|
||||
if(context.setLineDash) {
|
||||
context.setLineDash(dashArray);
|
||||
}
|
||||
else {
|
||||
Kinetic.Global.warn('Could not apply dash array because your browser does not support it.');
|
||||
}
|
||||
}
|
||||
if(!skipShadow && shadow) {
|
||||
this._applyShadow(shape);
|
||||
}
|
||||
@@ -219,6 +228,12 @@
|
||||
context.shadowOffsetX = offset.x;
|
||||
context.shadowOffsetY = offset.y;
|
||||
}
|
||||
},
|
||||
_applyLineCap: function(shape) {
|
||||
var lineCap = shape.getLineCap();
|
||||
if(lineCap) {
|
||||
this.context.lineCap = lineCap;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -237,12 +252,19 @@
|
||||
_stroke: function(shape) {
|
||||
var context = this.context, stroke = shape.getStroke(), strokeWidth = shape.getStrokeWidth();
|
||||
if(stroke || strokeWidth) {
|
||||
this._applyLineCap(shape);
|
||||
context.save();
|
||||
context.lineWidth = strokeWidth || 2;
|
||||
context.strokeStyle = '#' + shape.colorKey;
|
||||
context.stroke(context);
|
||||
context.restore();
|
||||
}
|
||||
},
|
||||
_applyLineCap: function(shape) {
|
||||
var lineCap = shape.getLineCap();
|
||||
if(lineCap) {
|
||||
this.context.lineCap = lineCap;
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user