Document different constructors of Point, Rectangle & Size.

This commit is contained in:
Jonathan Puckey 2011-05-28 02:38:33 +02:00
parent d644bbaa09
commit 9cc3b03f83
3 changed files with 72 additions and 5 deletions

View file

@ -39,6 +39,28 @@ var Point = this.Point = Base.extend({
* console.log(point.y); // 5
* </pre>
*/
/**
* Creates a Point object using the width and height values of the given
* Size object.
*
* Sample code:
* <code>
* // Create a Size with a width of 100pt and a height of 50pt
* var size = new Size(100, 50);
* console.log(size); // { width: 100, height: 50 }
* var point = new Point(size);
* console.log(point); // { x: 100, y: 50 }
* </code>
*
* @name Point#initialize
* @param {Size} size
*/
/**
* Creates a Point object using the coordinates of the given Point object.
*
* @param {Point} point
* @name Point#initialize
*/
initialize: function(arg0, arg1) {
if (arg1 !== undefined) {
this.x = arg0;

View file

@ -30,6 +30,30 @@ var Rectangle = this.Rectangle = Base.extend({
* point (x, y), its width, and its height. It should not be confused with a
* rectangular path, it is not an item.
*/
/**
* Creates a rectangle object.
*
* @name Rectangle#initialize
* @param {Number} x the left coordinate
* @param {Number} y the top coordinate
* @param {Number} width
* @param {Number} height
*/
/**
* Creates a rectangle object 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.
*
* @name Rectangle#initialize
* @param {Point} point1 The first point defining the rectangle
* @param {Point} point2 The second point defining the rectangle
*/
/**
* Creates a new rectangle object from the passed rectangle object.
*
* @name Rectangle#initialize
* @param {Rectangle} rt
*/
initialize: function(arg0, arg1, arg2, arg3) {
if (arguments.length == 4) {
// new Rectangle(x, y, width, height)

View file

@ -19,12 +19,11 @@ var Size = this.Size = Base.extend({
// DOCS: improve Size class description
/**
* Creates a Size object with the given width and height values.
*
* @name Size
* Creates a Size object using the coordinates of the given Size object.
*
* @constructor
* @param {Number} width the width
* @param {Number} height the height
* @name Size
* @param {Size} size
*
* @class The Size object represents the size of something.
*
@ -36,6 +35,28 @@ var Size = this.Size = Base.extend({
* console.log(size.height); // 5
* </pre>
*/
/**
* Creates a Point object using the x and y values of the given Point
* object.
*
* Sample code:
* <code>
* var point = new Point(50, 50);
* var size = new Size(point);
* console.log(size.width); // 50
* console.log(size.height); // 50
* </code>
*
* @name Size#initialize
* @param {Point} point
*/
/**
* Creates a Size object with the given width and height values.
*
* @name Size#initialize
* @param {Number} width the width
* @param {Number} height the height
*/
initialize: function(arg0, arg1) {
if (arg1 !== undefined) {
this.width = arg0;