paper.js/test/tests/PlacedSymbol.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-05-21 14:33:08 -04:00
module('Symbol & Placed Symbol');
test('placedSymbol bounds', function() {
var path = new Path.Circle([50, 50], 50);
2011-05-18 14:08:52 -04:00
path.strokeColor = 'black';
path.strokeWidth = 1;
path.strokeCap = 'round';
path.strokeJoin = 'round';
compareRectangles(path.strokeBounds,
{ x: -0.5, y: -0.5, width: 101, height: 101 },
'Path initial bounds.');
var symbol = new Symbol(path);
var placedSymbol = new PlacedSymbol(symbol);
2011-03-06 19:01:26 -05:00
compareRectangles(placedSymbol.bounds,
new Rectangle(-50.5, -50.5, 101, 101),
'PlacedSymbol initial bounds.');
2011-03-06 19:01:26 -05:00
placedSymbol.scale(1, 0.5);
compareRectangles(placedSymbol.bounds,
{ x: -50.5, y: -25.25, width: 101, height: 50.5 },
'Bounds after scale.');
placedSymbol.rotate(40);
compareRectangles(placedSymbol.bounds,
{ x: -42.04736, y: -37.91846, width: 84.09473, height: 75.83691 },
'Bounds after rotation.');
2011-03-06 10:14:57 -05:00
});
2011-05-21 14:32:41 -04:00
test('Symbol definition selection', function() {
var path = new Path.Circle([50, 50], 50);
path.selected = true;
var symbol = new Symbol(path);
equals(function() {
2011-05-21 15:28:30 -04:00
return symbol.definition.selected == false;
2011-05-21 14:32:41 -04:00
}, true);
2011-05-21 15:31:41 -04:00
equals(function() {
return paper.project.selectedItems.length == 0;
}, true);
2011-05-21 14:32:41 -04:00
});