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

Side by Side Diff: samples/spirodraw/web/colorpicker.dart

Issue 13726010: Rename context2d to context2D. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
« no previous file with comments | « samples/solar/web/solar.dart ('k') | samples/spirodraw/web/spirodraw.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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'];
11 static const COLS = 18; 11 static const COLS = 18;
12 // Block height, width, padding 12 // Block height, width, padding
13 static const BH = 10; 13 static const BH = 10;
14 static const BW = 10; 14 static const BW = 10;
15 static const BP = 1; 15 static const BP = 1;
16 final List<PickerListener> _listeners; 16 final List<PickerListener> _listeners;
17 CanvasElement canvasElement; 17 CanvasElement canvasElement;
18 String _selectedColor = 'red'; 18 String _selectedColor = 'red';
19 final height = 160; 19 final height = 160;
20 final width = 180; 20 final width = 180;
21 CanvasRenderingContext2D ctx; 21 CanvasRenderingContext2D ctx;
22 22
23 ColorPicker(this.canvasElement) : 23 ColorPicker(this.canvasElement) :
24 _listeners = [] 24 _listeners = []
25 { 25 {
26 ctx = canvasElement.context2d; 26 ctx = canvasElement.context2D;
27 drawPalette(); 27 drawPalette();
28 addHandlers(); 28 addHandlers();
29 showSelected(); 29 showSelected();
30 } 30 }
31 31
32 String get selectedColor => _selectedColor; 32 String get selectedColor => _selectedColor;
33 33
34 void set selectedColor(String color) { 34 void set selectedColor(String color) {
35 _selectedColor = color; 35 _selectedColor = color;
36 36
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 int i = value.floor().toInt(); 110 int i = value.floor().toInt();
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
« no previous file with comments | « samples/solar/web/solar.dart ('k') | samples/spirodraw/web/spirodraw.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698