| Index: chrome/browser/resources/print_preview/data/coordinate2d.js
|
| diff --git a/chrome/browser/resources/print_preview/data/coordinate2d.js b/chrome/browser/resources/print_preview/data/coordinate2d.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4b10af63808508e18669be00dfaab9f0d1986602
|
| --- /dev/null
|
| +++ b/chrome/browser/resources/print_preview/data/coordinate2d.js
|
| @@ -0,0 +1,76 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +cr.define('print_preview', function() {
|
| + 'use strict';
|
| +
|
| + /**
|
| + * Immutable two dimensional point in space. The units of the dimensions are
|
| + * undefined.
|
| + * @param {number} x X-dimension of the point.
|
| + * @param {number} y Y-dimension of the point.
|
| + * @constructor
|
| + */
|
| + function Coordinate2d(x, y) {
|
| + /**
|
| + * X-dimension of the point.
|
| + * @type {number}
|
| + * @private
|
| + */
|
| + this.x_ = x;
|
| +
|
| + /**
|
| + * Y-dimension of the point.
|
| + * @type {number}
|
| + * @private
|
| + */
|
| + this.y_ = y;
|
| + };
|
| +
|
| + Coordinate2d.prototype = {
|
| + /** @return {number} X-dimension of the point. */
|
| + get x() {
|
| + return this.x_;
|
| + },
|
| +
|
| + /** @return {number} Y-dimension of the point. */
|
| + get y() {
|
| + return this.y_;
|
| + },
|
| +
|
| + /**
|
| + * @param {number} x Amount to translate in the X dimension.
|
| + * @param {number} y Amount to translate in the Y dimension.
|
| + * @return {!print_preview.Coordinate2d} A new two-dimensional point
|
| + * translated along the X and Y dimensions.
|
| + */
|
| + translate: function(x, y) {
|
| + return new Coordinate2d(this.x_ + x, this.y_ + y);
|
| + },
|
| +
|
| + /**
|
| + * @param {number} factor Amount to scale the X and Y dimensions.
|
| + * @return {!print_preview.Coordinate2d} A new two-dimensional point scaled
|
| + * by the given factor.
|
| + */
|
| + scale: function(factor) {
|
| + return new Coordinate2d(this.x_ * factor, this.y_ * factor);
|
| + },
|
| +
|
| + /**
|
| + * @param {print_preview.Coordinate2d} other The point to compare against.
|
| + * @return {boolean} Whether another point is equal to this one.
|
| + */
|
| + equals: function(other) {
|
| + return other != null &&
|
| + this.x_ == other.x_ &&
|
| + this.y_ == other.y_;
|
| + }
|
| + };
|
| +
|
| + // Export
|
| + return {
|
| + Coordinate2d: Coordinate2d
|
| + };
|
| +});
|
|
|