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

Side by Side Diff: charted/lib/core/utils/rect.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « charted/lib/core/utils/object_factory.dart ('k') | charted/lib/layout/layout.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 //
2 // Copyright 2014 Google Inc. All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 //
8
9 part of charted.core.utils;
10
11 /// Interface representing size and position of an element
12 class Rect {
13 final num x;
14 final num y;
15 final num width;
16 final num height;
17
18 const Rect([this.x = 0, this.y = 0, this.width = 0, this.height = 0]);
19 const Rect.size(this.width, this.height) : x = 0, y = 0;
20 const Rect.position(this.x, this.y) : width = 0, height = 0;
21
22 bool operator==(other) =>
23 other is Rect && isSameSizeAs(other) && isSamePositionAs(other);
24
25 bool isSameSizeAs(Rect other) =>
26 other != null && width == other.width && height == other.height;
27
28 bool isSamePositionAs(Rect other) =>
29 other != null && x == other.x && y == other.y;
30
31 bool contains(num otherX, num otherY) =>
32 otherX >= x && otherX <= x + width &&
33 otherY >= y && otherY <= y + height;
34
35 String toString() => '$x, $y, $width, $height';
36 }
37
38 /// Mutable version of [Rect] class.
39 class MutableRect extends Rect {
40 num x;
41 num y;
42 num width;
43 num height;
44
45 MutableRect(this.x, this.y, this.width, this.height);
46 MutableRect.size(this.width, this.height);
47 MutableRect.position(this.x, this.y);
48 }
49
50 class AbsoluteRect {
51 final num start;
52 final num end;
53 final num top;
54 final num bottom;
55
56 const AbsoluteRect(this.top, this.end, this.bottom, this.start);
57
58 bool operator==(other) =>
59 other is AbsoluteRect &&
60 start == other.start && end == other.end &&
61 top == other.top && bottom == other.bottom;
62 }
OLDNEW
« no previous file with comments | « charted/lib/core/utils/object_factory.dart ('k') | charted/lib/layout/layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698