diff --git a/src/path/Path.Constructors.js b/src/path/Path.Constructors.js index 84ea9138..8720a2a9 100644 --- a/src/path/Path.Constructors.js +++ b/src/path/Path.Constructors.js @@ -258,7 +258,7 @@ Path.inject({ statics: new function() { * Creates a regular polygon shaped Path Item. * * @param {Point} center the center point of the polygon - * @param {Number} numSides the number of sides of the polygon + * @param {Number} sides the number of sides of the polygon * @param {Number} radius the radius of the polygon * @return {Path} the newly created path * @@ -276,17 +276,17 @@ Path.inject({ statics: new function() { * var triangle = new Path.RegularPolygon(center, sides, radius); * triangle.fillColor = 'black'; */ - RegularPolygon: function(/* center, numSides, radius */) { + RegularPolygon: function(/* center, sides, radius */) { var center = Point.readNamed(arguments, 'center'), - numSides = Base.readNamed(arguments, 'numSides'), + sides = Base.readNamed(arguments, 'sides'), radius = Base.readNamed(arguments, 'radius'), path = createPath(arguments), - step = 360 / numSides, - three = !(numSides % 3), + step = 360 / sides, + three = !(sides % 3), vector = new Point(0, three ? -radius : radius), offset = three ? -1 : 0.5, - segments = new Array(numSides); - for (var i = 0; i < numSides; i++) { + segments = new Array(sides); + for (var i = 0; i < sides; i++) { segments[i] = new Segment(center.add( vector.rotate((i + offset) * step))); } diff --git a/test/tests/Path_Shapes.js b/test/tests/Path_Shapes.js index a3c8bf5e..aceefa92 100644 --- a/test/tests/Path_Shapes.js +++ b/test/tests/Path_Shapes.js @@ -75,7 +75,7 @@ test('new Path.Arc({ from: from, through: through, to: to })', function() { equals(path.segments.toString(), '{ point: { x: 0, y: 20 }, handleOut: { x: -2.62559, y: 23.01251 } },{ point: { x: 30.89325, y: 74.75812 }, handleIn: { x: -21.05455, y: -9.65273 }, handleOut: { x: 21.05455, y: 9.65273 } },{ point: { x: 92.54397, y: 62.42797 }, handleIn: { x: -15.72238, y: 17.00811 }, handleOut: { x: 15.72238, y: -17.00811 } },{ point: { x: 100, y: 0 }, handleIn: { x: 11.27458, y: 20.23247 } }'); }); -test('new Path.RegularPolygon(center, numSides, radius)', function() { +test('new Path.RegularPolygon(center, sides, radius)', function() { var path = new Path.RegularPolygon(new Point(50, 50), 3, 10); equals(path.segments.toString(), '{ point: { x: 41.33975, y: 55 } },{ point: { x: 50, y: 40 } },{ point: { x: 58.66025, y: 55 } }'); @@ -83,11 +83,11 @@ test('new Path.RegularPolygon(center, numSides, radius)', function() { equals(path.segments.toString(), '{ point: { x: 219.0983, y: 345.10565 } },{ point: { x: 169.0983, y: 308.77853 } },{ point: { x: 150, y: 250 } },{ point: { x: 169.0983, y: 191.22147 } },{ point: { x: 219.0983, y: 154.89435 } },{ point: { x: 280.9017, y: 154.89435 } },{ point: { x: 330.9017, y: 191.22147 } },{ point: { x: 350, y: 250 } },{ point: { x: 330.9017, y: 308.77853 } },{ point: { x: 280.9017, y: 345.10565 } }'); }); -test('new Path.RegularPolygon({ center: center, numSides: numSides, radius: radius })', function() { - var path = new Path.RegularPolygon({center: new Point(50, 50), numSides: 3, radius: 10}); +test('new Path.RegularPolygon({ center: center, sides: sides, radius: radius })', function() { + var path = new Path.RegularPolygon({center: new Point(50, 50), sides: 3, radius: 10}); equals(path.segments.toString(), '{ point: { x: 41.33975, y: 55 } },{ point: { x: 50, y: 40 } },{ point: { x: 58.66025, y: 55 } }'); - var path = new Path.RegularPolygon({center: new Point(250, 250), numSides: 10, radius: 100}); + var path = new Path.RegularPolygon({center: new Point(250, 250), sides: 10, radius: 100}); equals(path.segments.toString(), '{ point: { x: 219.0983, y: 345.10565 } },{ point: { x: 169.0983, y: 308.77853 } },{ point: { x: 150, y: 250 } },{ point: { x: 169.0983, y: 191.22147 } },{ point: { x: 219.0983, y: 154.89435 } },{ point: { x: 280.9017, y: 154.89435 } },{ point: { x: 330.9017, y: 191.22147 } },{ point: { x: 350, y: 250 } },{ point: { x: 330.9017, y: 308.77853 } },{ point: { x: 280.9017, y: 345.10565 } }'); });