Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: samples/spirodraw/ColorPicker.dart

Issue 11748016: Make ~/, round, ceil, floor, truncate return ints. Remove toInt. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Checked mode fixes. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698