| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 import 'dart:html'; | 5 import 'dart:html'; |
| 6 import 'dart:svg'; | 6 import 'dart:svg'; |
| 7 import 'dart:math' as Math; | 7 import 'dart:math' as Math; |
| 8 | 8 |
| 9 class Color { | 9 class Color { |
| 10 int hue; | 10 int hue; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 double s; | 37 double s; |
| 38 if (max == min) { | 38 if (max == min) { |
| 39 s = 0.0; | 39 s = 0.0; |
| 40 } else if (l < 0.5) { | 40 } else if (l < 0.5) { |
| 41 s = d/(2*l); | 41 s = d/(2*l); |
| 42 } else { | 42 } else { |
| 43 s = d/(2 - 2*l); | 43 s = d/(2 - 2*l); |
| 44 } | 44 } |
| 45 | 45 |
| 46 return new Color((h.round() % 360).toInt(), s, l); | 46 return new Color(h.round() % 360, s, l); |
| 47 } | 47 } |
| 48 | 48 |
| 49 factory Color.fromHex(String hex) => new Color.rgb( | 49 factory Color.fromHex(String hex) => new Color.rgb( |
| 50 _parseHex(hex.substring(1, 3))/255, | 50 _parseHex(hex.substring(1, 3))/255, |
| 51 _parseHex(hex.substring(3, 5))/255, | 51 _parseHex(hex.substring(3, 5))/255, |
| 52 _parseHex(hex.substring(5, 7))/255); | 52 _parseHex(hex.substring(5, 7))/255); |
| 53 | 53 |
| 54 // This should be in the core library. Issue #233 | 54 // This should be in the core library. Issue #233 |
| 55 static int _parseHex(String hex) { | 55 static int _parseHex(String hex) { |
| 56 final codes = hex.charCodes; | 56 final codes = hex.charCodes; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 document.query("input[name=invert]").on.change.add((Event e) { | 191 document.query("input[name=invert]").on.change.add((Event e) { |
| 192 InputElement invert = e.target; | 192 InputElement invert = e.target; |
| 193 if (invert.checked) { | 193 if (invert.checked) { |
| 194 logo.classes = ['inverse']; | 194 logo.classes = ['inverse']; |
| 195 } else { | 195 } else { |
| 196 logo.classes = []; | 196 logo.classes = []; |
| 197 } | 197 } |
| 198 }); | 198 }); |
| 199 } | 199 } |
| OLD | NEW |