changed commands property to data per Jason's request. This provides a similar nomenclature to the SVG path data property

This commit is contained in:
Eric Rowell
2012-05-29 21:34:04 -07:00
parent 2bc0465186
commit 84e400e0f0
4 changed files with 429 additions and 276 deletions

View File

@@ -1189,7 +1189,7 @@ Test.prototype.tests = {
var layer = new Kinetic.Layer();
var path = new Kinetic.Path({
commands: 'M200,100h100v50z',
data: 'M200,100h100v50z',
fill: '#ccc',
stroke: '#333',
strokeWidth: 2,
@@ -1216,15 +1216,15 @@ Test.prototype.tests = {
stage.add(layer);
test(path.getCommands() === 'M200,100h100v50z', 'commands are incorrect');
test(path.getCommandsArray().length === 4, 'commands array should have 4 elements');
test(path.getData() === 'M200,100h100v50z', 'data are incorrect');
test(path.getDataArray().length === 4, 'data array should have 4 elements');
path.setCommands('M200');
path.setData('M200');
test(path.getCommands() === 'M200', 'commands are incorrect');
test(path.getCommandsArray().length === 1, 'commands array should have 1 element');
test(path.getData() === 'M200', 'data are incorrect');
test(path.getDataArray().length === 1, 'data array should have 1 element');
path.setCommands('M200,100h100v50z');
path.setData('M200,100h100v50z');
},
'SHAPE - moveTo with implied lineTos and trailing comma': function(containerId) {
@@ -1239,7 +1239,7 @@ Test.prototype.tests = {
var layer = new Kinetic.Layer();
var path = new Kinetic.Path({
commands: 'm200,100,100,0,0,50,z',
data: 'm200,100,100,0,0,50,z',
fill: '#fcc',
stroke: '#333',
strokeWidth: 2,
@@ -1266,10 +1266,10 @@ Test.prototype.tests = {
stage.add(layer);
test(path.getCommands() === 'm200,100,100,0,0,50,z', 'commands are incorrect');
test(path.getCommandsArray().length === 4, 'commands array should have 4 elements');
test(path.getData() === 'm200,100,100,0,0,50,z', 'data are incorrect');
test(path.getDataArray().length === 4, 'data array should have 4 elements');
test(path.getCommandsArray()[1].command === 'L', 'second command should be an implied lineTo');
test(path.getDataArray()[1].command === 'L', 'second command should be an implied lineTo');
},
'SHAPE - add map path': function(containerId) {
var stage = new Kinetic.Stage({
@@ -1287,14 +1287,14 @@ Test.prototype.tests = {
var c = worldMap.shapes[key];
var path = new Kinetic.Path({
commands: c,
data: c,
fill: '#ccc',
stroke: '#999',
strokeWidth: 1,
});
if (key === 'US')
test(path.getCommandsArray()[0].command === 'M', 'first command should be a moveTo');
test(path.getDataArray()[0].command === 'M', 'first command should be a moveTo');
path.on('mouseover', function() {
this.setFill('red');
@@ -1327,7 +1327,7 @@ Test.prototype.tests = {
var c = "M12.582,9.551C3.251,16.237,0.921,29.021,7.08,38.564l-2.36,1.689l4.893,2.262l4.893,2.262l-0.568-5.36l-0.567-5.359l-2.365,1.694c-4.657-7.375-2.83-17.185,4.352-22.33c7.451-5.338,17.817-3.625,23.156,3.824c5.337,7.449,3.625,17.813-3.821,23.152l2.857,3.988c9.617-6.893,11.827-20.277,4.935-29.896C35.591,4.87,22.204,2.658,12.582,9.551z";
var path = new Kinetic.Path({
commands: c,
data: c,
fill: '#ccc',
stroke: '#999',
strokeWidth: 1,
@@ -1362,7 +1362,7 @@ Test.prototype.tests = {
var c = "M200,300 Q400,50 600,300 T1000,300";
var path = new Kinetic.Path({
commands: c,
data: c,
stroke: 'red',
strokeWidth: 5,
});
@@ -1405,7 +1405,7 @@ Test.prototype.tests = {
}));
layer.add(new Kinetic.Path({
commands: "M200,300 L400,50L600,300L800,550L1000,300",
data: "M200,300 L400,50L600,300L800,550L1000,300",
stroke: "#888",
strokeWidth: 2
}));
@@ -1428,7 +1428,7 @@ Test.prototype.tests = {
var c = "M100,200 C100,100 250,100 250,200 S400,300 400,200";
var path = new Kinetic.Path({
commands: c,
data: c,
stroke: 'red',
strokeWidth: 5,
});