mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
53 lines
No EOL
2 KiB
JavaScript
53 lines
No EOL
2 KiB
JavaScript
module('Segment');
|
|
test('new Segment(point)', function() {
|
|
var segment = new Segment(new Point(10, 10));
|
|
equals(segment.toString(), '{ point: { x: 10, y: 10 } }');
|
|
});
|
|
|
|
test('new Segment(x, y)', function() {
|
|
var segment = new Segment(10, 10);
|
|
equals(segment.toString(), '{ point: { x: 10, y: 10 } }');
|
|
});
|
|
|
|
test('new Segment(object)', function() {
|
|
var segment = new Segment({ point: { x: 10, y: 10 }, handleIn: { x: 5, y: 5 }, handleOut: { x: 15, y: 15 } });
|
|
equals(segment.toString(), '{ point: { x: 10, y: 10 }, handleIn: { x: 5, y: 5 }, handleOut: { x: 15, y: 15 } }');
|
|
});
|
|
|
|
test('new Segment(point, handleIn, handleOut)', function() {
|
|
var segment = new Segment(new Point(10, 10), new Point(5, 5), new Point(15, 15));
|
|
equals(segment.toString(), '{ point: { x: 10, y: 10 }, handleIn: { x: 5, y: 5 }, handleOut: { x: 15, y: 15 } }');
|
|
});
|
|
|
|
test('new Segment(x, y, inX, inY, outX, outY)', function() {
|
|
var segment = new Segment(10, 10, 5, 5, 15, 15);
|
|
equals(segment.toString(), '{ point: { x: 10, y: 10 }, handleIn: { x: 5, y: 5 }, handleOut: { x: 15, y: 15 } }');
|
|
});
|
|
|
|
test('segment.reverse()', function() {
|
|
var segment = new Segment(new Point(10, 10), new Point(5, 5), new Point(15, 15));
|
|
segment = segment.reverse();
|
|
equals(segment.toString(), '{ point: { x: 10, y: 10 }, handleIn: { x: 15, y: 15 }, handleOut: { x: 5, y: 5 } }');
|
|
});
|
|
|
|
test('segment.clone()', function() {
|
|
var segment = new Segment(new Point(10, 10), new Point(5, 5), new Point(15, 15));
|
|
var clone = segment.clone();
|
|
equals(segment == clone, false);
|
|
equals(segment.toString(), clone.toString());
|
|
});
|
|
|
|
test('segment.remove()', function() {
|
|
var path = new Path([10, 10], [5, 5], [10, 10]);
|
|
path.segments[1].remove();
|
|
equals(path.segments.toString(), '{ point: { x: 10, y: 10 } },{ point: { x: 10, y: 10 } }');
|
|
});
|
|
|
|
test('segment.selected', function() {
|
|
var path = new Path([10, 20], [50, 100]);
|
|
path.segments[0].point.selected = true;
|
|
equals(path.segments[0].point.selected, true);
|
|
|
|
path.segments[0].point.selected = false;
|
|
equals(path.segments[0].point.selected, false);
|
|
}); |