| 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 part of spirodraw; | 5 part of spirodraw; |
| 6 | 6 |
| 7 typedef void PickerListener(String selectedColor); | 7 typedef void PickerListener(String selectedColor); |
| 8 | 8 |
| 9 class ColorPicker { | 9 class ColorPicker { |
| 10 static const hexValues = const ['00', '33', '66', '99', 'CC', 'FF']; | 10 static const hexValues = const ['00', '33', '66', '99', 'CC', 'FF']; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 void showSelected() { | 102 void showSelected() { |
| 103 ctx.fillStyle = _selectedColor; | 103 ctx.fillStyle = _selectedColor; |
| 104 ctx.fillRect(width / 2, 0, width / 2, 30); | 104 ctx.fillRect(width / 2, 0, width / 2, 30); |
| 105 ctx.fillStyle = "white"; | 105 ctx.fillStyle = "white"; |
| 106 ctx.fillRect(0, 0, width / 2, 30); | 106 ctx.fillRect(0, 0, width / 2, 30); |
| 107 } | 107 } |
| 108 | 108 |
| 109 String getHexString(num value) { | 109 String getHexString(num value) { |
| 110 int i = value.floor().toInt(); | 110 int i = value.floor(); |
| 111 | 111 |
| 112 int r = (i ~/ 36) % 6; | 112 int r = (i ~/ 36) % 6; |
| 113 int g = (i % 36) ~/ 6; | 113 int g = (i % 36) ~/ 6; |
| 114 int b = i % 6; | 114 int b = i % 6; |
| 115 | 115 |
| 116 return '#${hexValues[r]}${hexValues[g]}${hexValues[b]}'; | 116 return '#${hexValues[r]}${hexValues[g]}${hexValues[b]}'; |
| 117 } | 117 } |
| 118 | 118 |
| 119 } | 119 } |
| OLD | NEW |