| 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 static int _parseHex(String hex) { | 54 static int _parseHex(String hex) { |
| 55 return int.parse(hex, radix: 16); | 55 return int.parse(hex, radix: 16); |
| 56 } | 56 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 document.query("input[name=invert]").onChange.listen((Event e) { | 175 document.query("input[name=invert]").onChange.listen((Event e) { |
| 176 InputElement invert = e.target; | 176 InputElement invert = e.target; |
| 177 if (invert.checked) { | 177 if (invert.checked) { |
| 178 logo.classes = ['inverse']; | 178 logo.classes = ['inverse']; |
| 179 } else { | 179 } else { |
| 180 logo.classes = []; | 180 logo.classes = []; |
| 181 } | 181 } |
| 182 }); | 182 }); |
| 183 } | 183 } |
| OLD | NEW |