EaselJS v0.8.2 API Documentation : easeljs/geom/Point.js

API Documentation for: 0.8.2
Show:

File:Point.js

  1. /*
  2. * Point
  3. * Visit http://createjs.com/ for documentation, updates and examples.
  4. *
  5. * Copyright (c) 2010 gskinner.com, inc.
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation
  9. * files (the "Software"), to deal in the Software without
  10. * restriction, including without limitation the rights to use,
  11. * copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following
  14. * conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28.  
  29. /**
  30. * @module EaselJS
  31. */
  32.  
  33. // namespace:
  34. this.createjs = this.createjs||{};
  35.  
  36. (function() {
  37. "use strict";
  38.  
  39.  
  40. // constructor:
  41. /**
  42. * Represents a point on a 2 dimensional x / y coordinate system.
  43. *
  44. * <h4>Example</h4>
  45. *
  46. * var point = new createjs.Point(0, 100);
  47. *
  48. * @class Point
  49. * @param {Number} [x=0] X position.
  50. * @param {Number} [y=0] Y position.
  51. * @constructor
  52. **/
  53. function Point(x, y) {
  54. this.setValues(x, y);
  55. // public properties:
  56. // assigned in the setValues method.
  57. /**
  58. * X position.
  59. * @property x
  60. * @type Number
  61. **/
  62. /**
  63. * Y position.
  64. * @property y
  65. * @type Number
  66. **/
  67. }
  68. var p = Point.prototype;
  69.  
  70. /**
  71. * <strong>REMOVED</strong>. Removed in favor of using `MySuperClass_constructor`.
  72. * See {{#crossLink "Utility Methods/extend"}}{{/crossLink}} and {{#crossLink "Utility Methods/promote"}}{{/crossLink}}
  73. * for details.
  74. *
  75. * There is an inheritance tutorial distributed with EaselJS in /tutorials/Inheritance.
  76. *
  77. * @method initialize
  78. * @protected
  79. * @deprecated
  80. */
  81. // p.initialize = function() {}; // searchable for devs wondering where it is.
  82.  
  83. // public methods:
  84. /**
  85. * Sets the specified values on this instance.
  86. * @method setValues
  87. * @param {Number} [x=0] X position.
  88. * @param {Number} [y=0] Y position.
  89. * @return {Point} This instance. Useful for chaining method calls.
  90. * @chainable
  91. */
  92. p.setValues = function(x, y) {
  93. this.x = x||0;
  94. this.y = y||0;
  95. return this;
  96. };
  97. /**
  98. * Copies all properties from the specified point to this point.
  99. * @method copy
  100. * @param {Point} point The point to copy properties from.
  101. * @return {Point} This point. Useful for chaining method calls.
  102. * @chainable
  103. */
  104. p.copy = function(point) {
  105. this.x = point.x;
  106. this.y = point.y;
  107. return this;
  108. };
  109. /**
  110. * Returns a clone of the Point instance.
  111. * @method clone
  112. * @return {Point} a clone of the Point instance.
  113. **/
  114. p.clone = function() {
  115. return new Point(this.x, this.y);
  116. };
  117.  
  118. /**
  119. * Returns a string representation of this object.
  120. * @method toString
  121. * @return {String} a string representation of the instance.
  122. **/
  123. p.toString = function() {
  124. return "[Point (x="+this.x+" y="+this.y+")]";
  125. };
  126. createjs.Point = Point;
  127. }());
  128.