OLD | NEW |
1 // 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 |
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 typedef void PickerListener(String selectedColor); | 5 typedef void PickerListener(String selectedColor); |
6 | 6 |
7 class ColorPicker { | 7 class ColorPicker { |
8 | 8 |
9 static final hexValues = ['00', '33', '66', '99', 'CC', 'FF']; | 9 static final hexValues = const ['00', '33', '66', '99', 'CC', 'FF']; |
10 static final COLS = 18; | 10 static final COLS = 18; |
11 // Block height, width, padding | 11 // Block height, width, padding |
12 static final BH = 10; | 12 static final BH = 10; |
13 static final BW = 10; | 13 static final BW = 10; |
14 static final BP = 1; | 14 static final BP = 1; |
15 final List<PickerListener> _listeners; | 15 final List<PickerListener> _listeners; |
16 HTMLCanvasElement canvasElement; | 16 HTMLCanvasElement canvasElement; |
17 String _selectedColor = 'red'; | 17 String _selectedColor = 'red'; |
18 final height = 160; | 18 final height = 160; |
19 final width = 180; | 19 final width = 180; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 String getHexString(int i) { | 106 String getHexString(int i) { |
107 int r = i ~/ 36; | 107 int r = i ~/ 36; |
108 int g = (i % 36) ~/ 6; | 108 int g = (i % 36) ~/ 6; |
109 int b = i % 6; | 109 int b = i % 6; |
110 return '#${hexValues[r]}${hexValues[g]}${hexValues[b]}'; | 110 return '#${hexValues[r]}${hexValues[g]}${hexValues[b]}'; |
111 } | 111 } |
112 | 112 |
113 } | 113 } |
OLD | NEW |