Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: chrome/browser/resources/print_preview/data/coordinate2d.js

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes broken tests Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 * @param {number} x X-dimension of the point.
12 * @param {number} y Y-dimension of the point.
13 * @constructor
14 */
15 function Coordinate2d(x, y) {
16 /**
17 * X-dimension of the point.
18 * @type {number}
19 * @private
20 */
21 this.x_ = x;
22
23 /**
24 * Y-dimension of the point.
25 * @type {number}
26 * @private
27 */
28 this.y_ = y;
29 };
30
31 Coordinate2d.prototype = {
32 /** @return {number} X-dimension of the point. */
33 get x() {
34 return this.x_;
35 },
36
37 /** @return {number} Y-dimension of the point. */
38 get y() {
39 return this.y_;
40 },
41
42 /**
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.
47 */
48 translate: function(x, y) {
49 return new Coordinate2d(this.x_ + x, this.y_ + y);
50 },
51
52 /**
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.
56 */
57 scale: function(factor) {
58 return new Coordinate2d(this.x_ * factor, this.y_ * factor);
59 },
60
61 /**
62 * @param {print_preview.Coordinate2d} other The point to compare against.
63 * @return {boolean} Whether another point is equal to this one.
64 */
65 equals: function(other) {
66 return other != null &&
67 this.x_ == other.x_ &&
68 this.y_ == other.y_;
69 }
70 };
71
72 // Export
73 return {
74 Coordinate2d: Coordinate2d
75 };
76 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698