Separated Fill and Stroke operations on Path so that it will only be filled when there's a "fill" attr. This prevents the Canvas path from being unexpectedly closed. https://github.com/ericdrowell/KineticJS/issues/567

This commit is contained in:
Jason Follas
2013-08-26 08:07:17 -04:00
parent cddf36b423
commit c93f4348b0
2 changed files with 44 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
(function() {
(function () {
/**
* Path constructor.
* @author Jason Follas
@@ -18,12 +18,12 @@
* scale: 2<br>
* });
*/
Kinetic.Path = function(config) {
Kinetic.Path = function (config) {
this.___init(config);
};
Kinetic.Path.prototype = {
___init: function(config) {
___init: function (config) {
this.dataArray = [];
var that = this;
@@ -32,15 +32,15 @@
this.className = 'Path';
this.dataArray = Kinetic.Path.parsePathData(this.getData());
this.on('dataChange.kinetic', function() {
this.on('dataChange.kinetic', function () {
that.dataArray = Kinetic.Path.parsePathData(this.getData());
});
},
drawFunc: function(canvas) {
drawFunc: function (canvas) {
var ca = this.dataArray, context = canvas.getContext();
// context position
context.beginPath();
for(var n = 0; n < ca.length; n++) {
for (var n = 0; n < ca.length; n++) {
var c = ca[n].command;
var p = ca[n].points;
switch (c) {
@@ -77,7 +77,10 @@
break;
}
}
canvas.fillStroke(this);
if (this.getFill() !== undefined)
canvas.fill(this);
canvas.stroke(this);
}
};
Kinetic.Util.extend(Kinetic.Path, Kinetic.Shape);