From d761c6c25f811669de5287fb48bb80cbbd71c265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 17 Jun 2013 08:54:42 -0700 Subject: [PATCH] Implement tests for Curve#getPointAt(). More to come. --- test/tests/Curve.js | 34 ++++++++++++++++++++++++++++++++++ test/tests/load.js | 1 + 2 files changed, 35 insertions(+) create mode 100644 test/tests/Curve.js diff --git a/test/tests/Curve.js b/test/tests/Curve.js new file mode 100644 index 00000000..9cb7fefa --- /dev/null +++ b/test/tests/Curve.js @@ -0,0 +1,34 @@ +/* + * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. + * http://paperjs.org/ + * + * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey + * http://lehni.org/ & http://jonathanpuckey.com/ + * + * Distributed under the MIT license. See LICENSE file for details. + * + * All rights reserved. + */ + +module('Curve'); + +test('Curve#getPointAt()', function() { + var curve = new Path.Circle({ + center: [100, 100], + radius: 100 + }).getFirstCurve(); + + var points = [ + [0, new Point(0, 100)], + [0.25, new Point(7.8585, 61.07549)], + [0.5, new Point(29.28932, 29.28932)], + [0.75, new Point(61.07549, 7.8585)], + [1, new Point(100, 0)] + ]; + + for (var i = 0; i < points.length; i++) { + var entry = points[i]; + comparePoints(curve.getPointAt(entry[0], true), entry[1], + 'curve.getPointAt(' + entry[0] + ', true);'); + } +}); diff --git a/test/tests/load.js b/test/tests/load.js index 4366db01..107d163a 100644 --- a/test/tests/load.js +++ b/test/tests/load.js @@ -31,6 +31,7 @@ /*#*/ include('Path.js'); /*#*/ include('Style.js'); +/*#*/ include('Curve.js'); /*#*/ include('Path_Shapes.js'); /*#*/ include('Path_Drawing_Commands.js'); /*#*/ include('Path_Curves.js');