Path.Constructors docs: move @example tags to the end of the comments and shorten the lines of the examples.

This commit is contained in:
Jonathan Puckey 2011-05-30 17:13:19 +02:00
parent 5b1a5229da
commit 16f521b8a2

View file

@ -28,15 +28,18 @@ Path.inject({ statics: new function() {
/** @lends Path */
/**
* {@grouptitle Shaped Paths}
* Creates a Path Item with two anchor points forming a line.
*
* @example
* var path = new Path.Line(new Point(20, 20, new Point(100, 100));
* path.strokeColor = 'black';
*
* @param {Point} pt1 the first anchor point of the path
* @param {Point} pt2 the second anchor point of the path
* @return {Path} the newly created path
*
* @example
* var from = new Point(20, 20);
* var to = new Point(100, 100);
* var path = new Path.Line(from, to);
* path.strokeColor = 'black';
*/
Line: function() {
var step = Math.floor(arguments.length / 2);
@ -49,39 +52,47 @@ Path.inject({ statics: new function() {
/**
* Creates a rectangle shaped Path Item from the passed point and size.
*
* @example
* var rectangle = new Rectangle(new Point(100, 100), new Size(100, 100));
* var path = new Path.Rectangle(rectangle);
*
* @name Path.Rectangle
* @param {Point} point
* @param {Size} size
* @return {Path} the newly created path
*
* @example
* var point = new Point(100, 100);
* var size = new Size(100, 100);
* var rectangle = new Rectangle(point, size);
* var path = new Path.Rectangle(rectangle);
* path.strokeColor = 'black';
*/
/**
* Creates a rectangle shaped Path Item from the passed points. These do not
* necessarily need to be the top left and bottom right corners, the
* constructor figures out how to fit a rectangle between them.
*
* @example
* var path = new Path.Rectangle(new Point(100, 100), new Point(200, 300));
*
* @name Path.Rectangle
* @param {Point} point1 The first point defining the rectangle
* @param {Point} point2 The second point defining the rectangle
* @return {Path} the newly created path
*
* @example
* var point = new Point(100, 100);
* var point2 = new Point(200, 300);
* var path = new Path.Rectangle(point, point2);
* path.strokeColor = 'black';
*/
/**
* Creates a rectangle shaped Path Item from the passed abstract
* {@link Rectangle}.
*
* @example
* var rectangle = new Rectangle(new Point(100, 100), new Size(100, 100));
* var path = new Path.Rectangle(rectangle);
* path.strokeColor = 'black';
*
* @param {Rectangle} rect
* @return {Path} the newly created path
*
* @example
* var point = new Point(100, 100);
* var size = new Size(100, 100);
* var rectangle = new Rectangle(point, size);
* var path = new Path.Rectangle(rectangle);
* path.strokeColor = 'black';
*/
Rectangle: function(rect) {
rect = Rectangle.read(arguments);
@ -98,14 +109,17 @@ Path.inject({ statics: new function() {
/**
* Creates a rectangular Path Item with rounded corners.
*
* @example
* var rectangle = new Rectangle(new Point(100, 100), new Size(100, 100));
* var path = new Path.RoundRectangle(rectangle, new Size(30, 30));
*
* @param {Rectangle} rect
* @param {Size} size the size of the rounded corners
* @return {Path} the newly created path
*
* @example
* var point = new Point(100, 100);
* var size = new Size(100, 100);
* var rectangle = new Rectangle(point, size);
* var cornerSize = new Size(30, 30);
* var path = new Path.RoundRectangle(rectangle, cornerSize);
*/
RoundRectangle: function(rect, size) {
if (arguments.length == 2) {
@ -141,10 +155,6 @@ Path.inject({ statics: new function() {
/**
* Creates an oval shaped Path Item.
*
* @example
* var rectangle = new Rectangle(new Point(100, 100), new Size(150, 100));
* var path = new Path.Oval(rectangle);
*
* @param {Rectangle} rect
* @param {boolean} [circumscribed=false] if this is set to true the
@ -152,6 +162,13 @@ Path.inject({ statics: new function() {
* it. If it's set to false the oval path will fit within the
* rectangle.
* @return {Path} the newly created path
*
* @example
* var topLeft = new Point(100, 100);
* var size = new Size(150, 100);
* var rectangle = new Rectangle(topLeft, size);
* var path = new Path.Oval(rectangle);
* path.fillColor = 'black';
*/
Oval: function(rect) {
rect = Rectangle.read(arguments);
@ -175,12 +192,12 @@ Path.inject({ statics: new function() {
/**
* Creates a circle shaped Path Item.
*
* @example
* var path = new Path.Circle(new Point(100, 100), 50);
*
* @param {Point} center the center point of the circle
* @param {Number} radius the radius of the circle
* @return {Path} the newly created path
*
* @example
* var path = new Path.Circle(new Point(100, 100), 50);
*/
Circle: function(center, radius) {
if (arguments.length == 3) {
@ -196,14 +213,17 @@ Path.inject({ statics: new function() {
/**
* Creates a circular arc shaped Path Item.
*
* @example
* var path = new Path.Arc(new Point(0, 0), new Point(100, 100),
* new Point(200, 150));
*
* @param {Point} from the starting point of the circular arc
* @param {Point} through the point the arc passes through
* @param {Point} to the end point of the arc
* @return {Path} the newly created path
*
* @example
* var start = new Point(0, 0);
* var through = new Point(100, 100);
* var to = new Point(200, 150);
* var path = new Path.Arc(start, through, to);
* path.strokeColor = 'black';
*/
Arc: function(from, through, to) {
var path = new Path();
@ -215,17 +235,26 @@ Path.inject({ statics: new function() {
/**
* Creates a regular polygon shaped Path Item.
*
* @example
* // Create a triangle shaped path
* var triangle = new Path.RegularPolygon(new Point(100, 100), 3, 50);
*
* // Create a decahedron shaped path
* var decahedron = new Path.RegularPolygon(new Point(200, 100), 10, 50);
*
* @param {Point} center the center point of the polygon
* @param {Number} numSides the number of sides of the polygon
* @param {Number} radius the radius of the polygon
* @return {Path} the newly created path
*
* @example
* // Create a triangle shaped path
* var center = new Point(100, 100);
* var sides = 3;
* var radius = 50;
* var triangle = new Path.RegularPolygon(center, sides, radius);
* triangle.fillColor = 'black';
*
* @example
* // Create a decahedron shaped path
* var center = new Point(100, 100);
* var sides = 10;
* var radius = 50;
* var decahedron = new Path.RegularPolygon(center, sides, radius);
* decahedron.fillColor = 'black';
*/
RegularPolygon: function(center, numSides, radius) {
center = Point.read(arguments, 0, 1);
@ -251,18 +280,19 @@ Path.inject({ statics: new function() {
* radius of the star. The smallest of radius1 and radius2 will be the
* inner radius.
*
* @example
* var center = new Point(100, 100);
* var points = 6;
* var innerRadius = 20;
* var outerRadius = 50;
* var path = new Path.Star(center, points, innerRadius, outerRadius);
*
* @param {Point} center the center point of the star
* @param {Number} numPoints the number of points of the star
* @param {Number} radius1
* @param {Number} radius2
* @return {Path} the newly created path
*
* @example
* var center = new Point(100, 100);
* var points = 6;
* var radius1 = 20;
* var radius2 = 50;
* var path = new Path.Star(center, points, radius1, radius2);
* path.fillColor = 'black';
*/
Star: function(center, numPoints, radius1, radius2) {
center = Point.read(arguments, 0, 1);