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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 final str = (color * 0xff).round().toRadixString(16); | 103 final str = (color * 0xff).round().toRadixString(16); |
104 return str.length == 1 ? '0$str' : str; | 104 return str.length == 1 ? '0$str' : str; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 SvgSvgElement logo; | 108 SvgSvgElement logo; |
109 InputElement hue, saturation, lightness; | 109 InputElement hue, saturation, lightness; |
110 Map<String, Color> defaultColors; | 110 Map<String, Color> defaultColors; |
111 | 111 |
112 onSliderChange(_) { | 112 onSliderChange(_) { |
113 final hueDelta = Math.parseInt(hue.value) - 180; | 113 final hueDelta = int.parse(hue.value) - 180; |
114 final saturationMod = Math.parseInt(saturation.value)/100; | 114 final saturationMod = int.parse(saturation.value)/100; |
115 final lightnessMod = Math.parseInt(lightness.value)/100; | 115 final lightnessMod = int.parse(lightness.value)/100; |
116 | 116 |
117 logo.queryAll("path").forEach((p) { | 117 logo.queryAll("path").forEach((p) { |
118 final color = defaultColors[p.id].dup(); | 118 final color = defaultColors[p.id].dup(); |
119 color.hue += hueDelta; | 119 color.hue += hueDelta; |
120 | 120 |
121 if (saturationMod > 0) { | 121 if (saturationMod > 0) { |
122 color.saturation += saturationMod * (1 - color.saturation); | 122 color.saturation += saturationMod * (1 - color.saturation); |
123 } else { | 123 } else { |
124 color.saturation += saturationMod * color.saturation; | 124 color.saturation += saturationMod * color.saturation; |
125 } | 125 } |
(...skipping 64 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 |