2011-07-01 06:17:45 -04:00
|
|
|
/*
|
2013-01-28 21:03:27 -05:00
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
2011-07-01 06:17:45 -04:00
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
2015-12-27 12:09:25 -05:00
|
|
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
2014-01-03 19:47:16 -05:00
|
|
|
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
2011-07-01 06:17:45 -04:00
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2016-01-27 13:57:07 -05:00
|
|
|
QUnit.module('Path Length');
|
2011-02-26 11:26:54 -05:00
|
|
|
|
|
|
|
test('path.length', function() {
|
2014-08-16 13:24:54 -04:00
|
|
|
var path = new Path([
|
|
|
|
new Segment(new Point(121, 334), new Point(-19, 38), new Point(30.7666015625, -61.53369140625)),
|
|
|
|
new Segment(new Point(248, 320), new Point(-42, -74), new Point(42, 74))
|
|
|
|
]);
|
2011-03-06 19:01:16 -05:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var length = path.length;
|
2014-11-30 14:27:14 -05:00
|
|
|
equals(length, 172.10112809179614, 'path.length');
|
2011-04-26 07:34:27 -04:00
|
|
|
|
2014-08-16 13:24:54 -04:00
|
|
|
var param = path.curves[0].getParameterAt(length / 4);
|
2014-11-30 14:27:14 -05:00
|
|
|
equals(param, 0.2255849553116685, 'path.curves[0].getParameterAt(length / 4)');
|
2011-02-26 11:26:54 -05:00
|
|
|
});
|
2011-04-11 12:58:32 -04:00
|
|
|
|
|
|
|
test('curve.getParameter with straight curve', function() {
|
2014-08-16 13:24:54 -04:00
|
|
|
var path = new Path();
|
|
|
|
path.moveTo(100, 100);
|
|
|
|
path.lineTo(500, 500);
|
|
|
|
var curve = path.curves[0];
|
|
|
|
var length = curve.length;
|
|
|
|
var t = curve.getParameterAt(length / 3);
|
2014-11-30 14:27:14 -05:00
|
|
|
equals(t, 0.3869631475722452);
|
2011-04-11 12:58:32 -04:00
|
|
|
});
|