1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 cr.define('print_preview', function() {
9 * Immutable two dimensional point in space. The units of the dimensions are
11 * @param {number} x X-dimension of the point.
12 * @param {number} y Y-dimension of the point.
15 function Coordinate2d(x, y) {
17 * X-dimension of the point.
24 * Y-dimension of the point.
31 Coordinate2d.prototype = {
32 /** @return {number} X-dimension of the point. */
37 /** @return {number} Y-dimension of the point. */
43 * @param {number} x Amount to translate in the X dimension.
44 * @param {number} y Amount to translate in the Y dimension.
45 * @return {!print_preview.Coordinate2d} A new two-dimensional point
46 * translated along the X and Y dimensions.
48 translate: function(x, y) {
49 return new Coordinate2d(this.x_ + x, this.y_ + y);
53 * @param {number} factor Amount to scale the X and Y dimensions.
54 * @return {!print_preview.Coordinate2d} A new two-dimensional point scaled
55 * by the given factor.
57 scale: function(factor) {
58 return new Coordinate2d(this.x_ * factor, this.y_ * factor);
62 * @param {print_preview.Coordinate2d} other The point to compare against.
63 * @return {boolean} Whether another point is equal to this one.
65 equals: function(other) {
66 return other != null &&
67 this.x_ == other.x_ &&
74 Coordinate2d: Coordinate2d