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

Unified Diff: tools/cc-frame-viewer/src/base/rect2.js

Issue 12225131: [cc] Initial checkin of cc-frame-viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/cc-frame-viewer/src/base/range_test.html ('k') | tools/cc-frame-viewer/src/base/unittest.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cc-frame-viewer/src/base/rect2.js
diff --git a/tools/cc-frame-viewer/src/base/rect2.js b/tools/cc-frame-viewer/src/base/rect2.js
new file mode 100644
index 0000000000000000000000000000000000000000..6c4857093aa1a788434bdc4a323c295494c5aa03
--- /dev/null
+++ b/tools/cc-frame-viewer/src/base/rect2.js
@@ -0,0 +1,60 @@
+// 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.
+'use strict';
+
+/**
+ * @fileoverview Quick range computations.
+ */
+base.require('base.gl_matrix');
+
+base.exportTo('base', function() {
+
+ /**
+ * Tracks a 2D bounding box.
+ * @constructor
+ */
+ function Rect2() {
+ this.left = 0;
+ this.top = 0;
+ this.width = 0;
+ this.height = 0;
+ };
+ Rect2.FromXYWH = function(x, y, w, h) {
+ var rect = new Rect2();
+ rect.left = x;
+ rect.top = y;
+ rect.width = w;
+ rect.height = h;
+ return rect;
+ }
+
+ Rect2.prototype = {
+ __proto__: Object.prototype,
+
+ translateXY: function(x, y) {
+ this.left += x;
+ this.top += y;
+ },
+
+ enlarge: function(pad) {
+ this.left -= pad;
+ this.top -= pad;
+ this.width += 2*pad;
+ this.height += 2*pad;
+ },
+
+ get right() {
+ return this.left + this.width;
+ },
+
+ get bottom() {
+ return this.left + this.width;
+ }
+ };
+
+ return {
+ Rect2: Rect2
+ };
+
+});
« no previous file with comments | « tools/cc-frame-viewer/src/base/range_test.html ('k') | tools/cc-frame-viewer/src/base/unittest.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698