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

Side by Side Diff: dart/samples/ui_lib/touch/Math.dart

Issue 11233061: Revert "Parts must start with 'part of'" and "Attempt to fix VM build" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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
1 part of touch;
2
3 // 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
4 // 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
5 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
6 4
7 // TODO(jacobr): pick a better name. This was goog.math in Closure. 5 // TODO(jacobr): pick a better name. This was goog.math in Closure.
8 /** 6 /**
9 * Math utility functions originally from the closure Math library. 7 * Math utility functions originally from the closure Math library.
10 */ 8 */
11 class GoogleMath { 9 class GoogleMath {
12 /** 10 /**
13 * Takes a [value] and clamps it to within the bounds specified by 11 * Takes a [value] and clamps it to within the bounds specified by
14 * [min] and [max]. 12 * [min] and [max].
15 */ 13 */
16 static num clamp(num value, num min, num max) { 14 static num clamp(num value, num min, num max) {
17 return Math.min(Math.max(value, min), max); 15 return Math.min(Math.max(value, min), max);
18 } 16 }
19 17
20 /** 18 /**
21 * Tests whether the two values are equal to each other, within a certain 19 * Tests whether the two values are equal to each other, within a certain
22 * tolerance to adjust for floating point errors. 20 * tolerance to adjust for floating point errors.
23 * The optional [tolerance] value d Defaults to 0.000001. If specified, 21 * The optional [tolerance] value d Defaults to 0.000001. If specified,
24 * it should be greater than 0. 22 * it should be greater than 0.
25 * Returns whether [a] and [b] are nearly equal. 23 * Returns whether [a] and [b] are nearly equal.
26 */ 24 */
27 static bool nearlyEquals(num a, num b, [num tolerance = 0.000001]) { 25 static bool nearlyEquals(num a, num b, [num tolerance = 0.000001]) {
28 return (a - b).abs() <= tolerance; 26 return (a - b).abs() <= tolerance;
29 } 27 }
30 } 28 }
OLDNEW
« no previous file with comments | « dart/samples/ui_lib/touch/InfiniteScroller.dart ('k') | dart/samples/ui_lib/touch/Momentum.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698