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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 SvgSvgElement logo; | 92 SvgSvgElement logo; |
93 InputElement hue, saturation, lightness; | 93 InputElement hue, saturation, lightness; |
94 Map<String, Color> defaultColors; | 94 Map<String, Color> defaultColors; |
95 | 95 |
96 onSliderChange(_) { | 96 onSliderChange(_) { |
97 final hueDelta = int.parse(hue.value) - 180; | 97 final hueDelta = int.parse(hue.value) - 180; |
98 final saturationMod = int.parse(saturation.value)/100; | 98 final saturationMod = int.parse(saturation.value)/100; |
99 final lightnessMod = int.parse(lightness.value)/100; | 99 final lightnessMod = int.parse(lightness.value)/100; |
100 | 100 |
101 logo.queryAll("path").forEach((p) { | 101 logo.querySelectorAll("path").forEach((p) { |
102 final color = defaultColors[p.id].dup(); | 102 final color = defaultColors[p.id].dup(); |
103 color.hue += hueDelta; | 103 color.hue += hueDelta; |
104 | 104 |
105 if (saturationMod > 0) { | 105 if (saturationMod > 0) { |
106 color.saturation += saturationMod * (1 - color.saturation); | 106 color.saturation += saturationMod * (1 - color.saturation); |
107 } else { | 107 } else { |
108 color.saturation += saturationMod * color.saturation; | 108 color.saturation += saturationMod * color.saturation; |
109 } | 109 } |
110 | 110 |
111 if (lightnessMod > 0) { | 111 if (lightnessMod > 0) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 d="m 273.04948,79.876866 c 0.072,0.02 0.148,0.044 0.22,0.064 l -0.004,-0.02
c -0.076,-0.02 -0.144,-0.024 -0.216,-0.044 z m 38.66001,20.576004 c -8.792,-8.8
60004 -24.37601,-16.912004 -38.44001,-20.512004 l 67.62801,191.727994 -21.24,47.
93601 -0.02,0.008 51.928,-16.592 0.1,-142.368 -59.956,-60.2 z" | 153 d="m 273.04948,79.876866 c 0.072,0.02 0.148,0.044 0.22,0.064 l -0.004,-0.02
c -0.076,-0.02 -0.144,-0.024 -0.216,-0.044 z m 38.66001,20.576004 c -8.792,-8.8
60004 -24.37601,-16.912004 -38.44001,-20.512004 l 67.62801,191.727994 -21.24,47.
93601 -0.02,0.008 51.928,-16.592 0.1,-142.368 -59.956,-60.2 z" |
154 id="path2908" | 154 id="path2908" |
155 style="fill: #008bc9" /> | 155 style="fill: #008bc9" /> |
156 <path | 156 <path |
157 d="M 263.78548,53.048866 220.45349,10.028873 c -10.02,-9.92799955 -23.664,-
13.0239996 -30.26,-6.8439996 L 77.677489,77.672866 l 174.239991,-0.036 8.64,0.30
8 c 3.9,0.124 8.228,0.832 12.708,1.98 l -9.48,-26.876 z m -186.111991,24.62" | 157 d="M 263.78548,53.048866 220.45349,10.028873 c -10.02,-9.92799955 -23.664,-
13.0239996 -30.26,-6.8439996 L 77.677489,77.672866 l 174.239991,-0.036 8.64,0.30
8 c 3.9,0.124 8.228,0.832 12.708,1.98 l -9.48,-26.876 z m -186.111991,24.62" |
158 id="path2910" | 158 id="path2910" |
159 style="fill: #75ccc3" /> | 159 style="fill: #75ccc3" /> |
160 </svg> | 160 </svg> |
161 """); | 161 """); |
162 | 162 |
163 query("#icon").children.add(logo); | 163 querySelector("#icon").children.add(logo); |
164 logo.queryAll("path").forEach((p) { | 164 logo.querySelectorAll("path").forEach((p) { |
165 defaultColors[p.id] = new Color.fromHex(p.style.getPropertyValue('fill')); | 165 defaultColors[p.id] = new Color.fromHex(p.style.getPropertyValue('fill')); |
166 }); | 166 }); |
167 | 167 |
168 hue = document.query("input[name=hue]"); | 168 hue = document.querySelector("input[name=hue]"); |
169 hue.onChange.listen(onSliderChange); | 169 hue.onChange.listen(onSliderChange); |
170 saturation = document.query("input[name=saturation]"); | 170 saturation = document.querySelector("input[name=saturation]"); |
171 saturation.onChange.listen(onSliderChange); | 171 saturation.onChange.listen(onSliderChange); |
172 lightness = document.query("input[name=lightness]"); | 172 lightness = document.querySelector("input[name=lightness]"); |
173 lightness.onChange.listen(onSliderChange); | 173 lightness.onChange.listen(onSliderChange); |
174 | 174 |
175 document.query("input[name=invert]").onChange.listen((Event e) { | 175 document.querySelector("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 |