aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/core/geometry/point.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/core/geometry/point.js')
-rwxr-xr-xnode_modules/montage/core/geometry/point.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/node_modules/montage/core/geometry/point.js b/node_modules/montage/core/geometry/point.js
new file mode 100755
index 00000000..cec433be
--- /dev/null
+++ b/node_modules/montage/core/geometry/point.js
@@ -0,0 +1,66 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module montage/core/geometry/point
8 @requires montage/core/core
9*/
10var Montage = require("montage").Montage;
11/**
12 @class module:montage/core/geometry/point.Point
13 @extends module:montage/core/core.Montage
14 */
15
16exports.Point = Montage.create(Montage, /** @lends module:montage/core/geometry/point.Point# */ {
17 init: {
18 enumerable: false,
19 value: function(x, y) {
20 this.x = x === null ? 0 : x;
21 this.y = y === null ? 0 : y;
22 return this;
23 }
24 },
25/**
26 Interpolates between two points.
27 @function
28 @param {Axis} percent The interpolation percentage.
29 @param {Axis} point0 The 0 interpolation point.
30 @param {Axis} point1 The 1 interpolation point.
31 @param {Axis} precision The interpolation precision.
32 @returns Montage.create(Point).init(xValue, yValue)
33 */
34 interpolate: {
35 enumerable: false,
36 value: function(percent, point0, point1, precision) {
37 var xValue,
38 yValue;
39 xValue = point0.x + (point1.x - point0.x) * percent;
40 yValue = point0.y + (point1.y - point0.y) * percent;
41 if (precision > 0) {
42 xValue = Math.round(xValue * precision) / precision;
43 yValue = Math.round(yValue * precision) / precision;
44 }
45 return exports.Point.create().init(xValue, yValue);
46 }
47 },
48/**
49 The x axis point.
50 @type {Number}
51 @default 0
52 */
53 x: {
54 enumerable: true,
55 value: 0
56 },
57/**
58 The y axis point.
59 @type {Number}
60 @default 0
61 */
62 y: {
63 enumerable: true,
64 value: 0
65 }
66});