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

Side by Side Diff: samples/swarm/swarm_ui_lib/touch/Geometry.dart

Issue 12493003: Exposing Point & Rect types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Sync to ToT Created 7 years, 9 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
« no previous file with comments | « samples/spirodraw/web/colorpicker.dart ('k') | samples/swarm/swarm_ui_lib/touch/Scrollbar.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of touch; 5 part of touch;
6 6
7 /** 7 /**
8 * Represents a point in 2 dimensional space. 8 * Represents a point in 2 dimensional space.
9 */ 9 */
10 class Coordinate { 10 class Coordinate {
11 11
12 /** 12 /**
13 * X-value 13 * X-value
14 */ 14 */
15 num x; 15 num x;
16 16
17 /** 17 /**
18 * Y-value 18 * Y-value
19 */ 19 */
20 num y; 20 num y;
21 21
22 Coordinate([num this.x = 0, num this.y = 0]) { 22 Coordinate([num this.x = 0, num this.y = 0]) {
23 } 23 }
24 24
25 /** 25 /**
26 * Gets the coordinates of a touch's location relative to the window's 26 * Gets the coordinates of a touch's location relative to the window's
27 * viewport. [input] is either a touch object or an event object. 27 * viewport. [input] is either a touch object or an event object.
28 */ 28 */
29 Coordinate.fromClient(var input) : this(input.clientX, input.clientY); 29 Coordinate.fromClient(var input) : this(input.client.x, input.client.y);
30 30
31 static Coordinate difference(Coordinate a, Coordinate b) { 31 static Coordinate difference(Coordinate a, Coordinate b) {
32 return new Coordinate(a.x - b.x, a.y - b.y); 32 return new Coordinate(a.x - b.x, a.y - b.y);
33 } 33 }
34 34
35 static num distance(Coordinate a, Coordinate b) { 35 static num distance(Coordinate a, Coordinate b) {
36 final dx = a.x - b.x; 36 final dx = a.x - b.x;
37 final dy = a.y - b.y; 37 final dy = a.y - b.y;
38 return Math.sqrt(dx * dx + dy * dy); 38 return Math.sqrt(dx * dx + dy * dy);
39 } 39 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 bool contains(num value) { 86 bool contains(num value) {
87 return value >= start && value < end; 87 return value >= start && value < end;
88 } 88 }
89 89
90 String toString() { 90 String toString() {
91 return '(${start}, ${end})'; 91 return '(${start}, ${end})';
92 } 92 }
93 } 93 }
OLDNEW
« no previous file with comments | « samples/spirodraw/web/colorpicker.dart ('k') | samples/swarm/swarm_ui_lib/touch/Scrollbar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698