2011-02-16 16:11:26 -05:00
|
|
|
module('Path Style');
|
|
|
|
|
|
|
|
test('currentStyle', function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
paper.project.currentStyle.fillColor = 'black';
|
2011-02-16 16:11:26 -05:00
|
|
|
var path = new Path();
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'black', 'path.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
2011-05-16 08:33:15 -04:00
|
|
|
// When changing the current style of the project, the style of
|
|
|
|
// paths created using project.currentStyle should not change.
|
|
|
|
paper.project.currentStyle.fillColor = 'red';
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'black', 'path.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('setting currentStyle to an object', function() {
|
2011-05-16 08:33:15 -04:00
|
|
|
paper.project.currentStyle = {
|
2011-02-16 16:11:26 -05:00
|
|
|
fillColor: 'red',
|
|
|
|
strokeColor: 'green'
|
|
|
|
};
|
|
|
|
var path = new Path();
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'red', 'path.fillColor');
|
|
|
|
compareRGBColors(path.strokeColor, 'green', 'path.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('setting path styles to an object', function() {
|
|
|
|
var path = new Path();
|
|
|
|
path.style = {
|
|
|
|
fillColor: 'red',
|
|
|
|
strokeColor: 'green'
|
|
|
|
};
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'red', 'path.fillColor');
|
|
|
|
compareRGBColors(path.strokeColor, 'green', 'path.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('setting group styles to an object', function() {
|
|
|
|
var group = new Group();
|
|
|
|
var path = new Path();
|
|
|
|
group.appendTop(path);
|
|
|
|
group.style = {
|
|
|
|
fillColor: 'red',
|
|
|
|
strokeColor: 'green'
|
|
|
|
};
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'red', 'path.fillColor');
|
|
|
|
compareRGBColors(path.strokeColor, 'green', 'path.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('getting group styles', function() {
|
|
|
|
var group = new Group();
|
|
|
|
var path = new Path();
|
|
|
|
path.fillColor = 'red';
|
|
|
|
group.appendTop(path);
|
|
|
|
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(group.fillColor, 'red', 'group.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
var secondPath = new Path();
|
|
|
|
secondPath.fillColor = 'black';
|
|
|
|
group.appendTop(secondPath);
|
|
|
|
|
|
|
|
// the group now contains two paths with different fillColors and therefore
|
2011-05-05 08:37:57 -04:00
|
|
|
// should return undefined:
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return group.fillColor;
|
|
|
|
}, undefined);
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
//If we remove the first path, it should now return 'black':
|
|
|
|
group.children[0].remove();
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(group.fillColor, 'black', 'group.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('setting group styles', function() {
|
|
|
|
var group = new Group();
|
|
|
|
var path = new Path();
|
|
|
|
path.fillColor = 'red';
|
|
|
|
group.appendTop(path);
|
|
|
|
|
|
|
|
var secondPath = new Path();
|
|
|
|
secondPath.fillColor = 'blue';
|
|
|
|
secondPath.strokeColor = 'red';
|
|
|
|
group.appendTop(secondPath);
|
|
|
|
|
|
|
|
// Change the fill color of the group:
|
|
|
|
group.fillColor = 'black';
|
|
|
|
|
|
|
|
// the paths contained in the group should now both have their fillColor
|
|
|
|
// set to black:
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'black', 'path.fillColor');
|
|
|
|
compareRGBColors(secondPath.fillColor, 'black', 'secondPath.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
// The second path still has its strokeColor set to red:
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(secondPath.strokeColor, 'red', 'secondPath.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
test('setting group styles 2', function() {
|
|
|
|
var group = new Group();
|
|
|
|
var path = new Path();
|
|
|
|
path.fillColor = 'red';
|
|
|
|
group.appendTop(path);
|
|
|
|
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(group.fillColor, 'red', 'group.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
var secondPath = new Path();
|
|
|
|
secondPath.fillColor = 'blue';
|
|
|
|
secondPath.strokeColor = 'red';
|
|
|
|
group.appendTop(secondPath);
|
|
|
|
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(secondPath.fillColor, 'blue', 'secondPath.fillColor');
|
|
|
|
compareRGBColors(secondPath.strokeColor, 'red', 'secondPath.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
// By appending a path with a different fillcolor,
|
2011-05-05 08:11:40 -04:00
|
|
|
// the group's fillColor should return undefined:
|
2011-05-07 12:46:06 -04:00
|
|
|
equals(function() {
|
|
|
|
return group.fillColor;
|
|
|
|
}, undefined);
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
// But, both paths have a red strokeColor, so:
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(group.strokeColor, 'red', 'group.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
// Change the fill color of the group's style:
|
|
|
|
group.style.fillColor = 'black';
|
|
|
|
|
|
|
|
// the paths contained in the group should now both have their fillColor
|
|
|
|
// set to black:
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(path.fillColor, 'black', 'path.fillColor');
|
|
|
|
compareRGBColors(secondPath.fillColor, 'black', 'secondPath.fillColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
|
|
|
|
// The second path still has its strokeColor set to red:
|
2011-05-05 08:11:17 -04:00
|
|
|
compareRGBColors(secondPath.strokeColor, 'red', 'secondPath.strokeColor');
|
2011-02-16 16:11:26 -05:00
|
|
|
});
|