Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 cr.define('print_preview', function() { | |
| 6 'use strict'; | |
| 7 | |
| 8 /** | |
| 9 * Immutable two dimensional point in space. The units of the dimensions are | |
| 10 * undefined. | |
| 11 * | |
| 12 * @param {number} x X-dimension of the point. | |
| 13 * @param {number} y Y-dimension of the point. | |
| 14 * @constructor | |
| 15 */ | |
| 16 function Coordinate2d(x, y) { | |
| 17 /** | |
| 18 * X-dimension of the point. | |
| 19 * @type {number} | |
| 20 * @private | |
| 21 */ | |
| 22 this.x_ = x; | |
| 23 | |
| 24 /** | |
| 25 * Y-dimension of the point. | |
| 26 * @type {number} | |
| 27 * @private | |
| 28 */ | |
| 29 this.y_ = y; | |
| 30 }; | |
| 31 | |
| 32 Coordinate2d.prototype = { | |
| 33 /** @return {number} X-dimension of the point. */ | |
| 34 get x() { | |
| 35 return this.x_; | |
| 36 }, | |
| 37 | |
| 38 /** @return {number} Y-dimension of the point. */ | |
| 39 get y() { | |
| 40 return this.y_; | |
| 41 }, | |
| 42 | |
| 43 /** | |
| 44 * @param {number} x Amount to translate in the X dimension. | |
| 45 * @param {number} y Amount to translate in the Y dimension. | |
| 46 * @return {!print_preview.Coordinate2d} A new two-dimensional point | |
| 47 * translated along the X and Y dimensions. | |
|
dpapad
2012/04/24 01:24:56
Nit: "translated" might fit in previous line, not
Robert Toscano
2012/04/24 22:29:56
3 chars too long.
| |
| 48 */ | |
| 49 translate: function(x, y) { | |
| 50 return new Coordinate2d(this.x_ + x, this.y_ + y); | |
| 51 }, | |
| 52 | |
| 53 /** | |
| 54 * @param {number} factor Amount to scale the X and Y dimensions. | |
| 55 * @return {!print_preview.Coordinate2d} A new two-dimensional point scaled | |
| 56 * by the given factor. | |
|
dpapad
2012/04/24 01:24:56
Nit: "by" can fit in previous line.
Robert Toscano
2012/04/24 22:29:56
No more room :(
| |
| 57 */ | |
| 58 scale: function(factor) { | |
| 59 return new Coordinate2d(this.x_ * factor, this.y_ * factor); | |
| 60 }, | |
| 61 | |
| 62 /** | |
| 63 * @param {print_preview.Coordinate2d} other The other two-dimensional | |
|
dpapad
2012/04/24 01:24:56
Nit: Shorter comment
The point to compare against.
Robert Toscano
2012/04/24 22:29:56
Nice, saved me a couple of lines.
| |
| 64 * coordinate to compare this coordinate against. | |
| 65 * @return {boolean} Whether another two-dimensional point is equal to | |
| 66 * this one. | |
| 67 */ | |
| 68 equals: function(other) { | |
| 69 return other != null && | |
| 70 this.x_ == other.x_ && | |
| 71 this.y_ == other.y_; | |
| 72 } | |
| 73 }; | |
| 74 | |
| 75 // Export | |
| 76 return { | |
| 77 Coordinate2d: Coordinate2d | |
| 78 }; | |
| 79 }); | |
| OLD | NEW |