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

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

Issue 12493003: Exposing Point & Rect types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Sync to ToT Created 7 years, 9 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/solar3d/web/solar.dart ('k') | samples/swarm/swarm_ui_lib/touch/Geometry.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'];
(...skipping 21 matching lines...) Expand all
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
37 showSelected(); 37 showSelected();
38 fireSelected(); 38 fireSelected();
39 } 39 }
40 40
41 void onMouseMove(MouseEvent event) { 41 void onMouseMove(MouseEvent event) {
42 int x = event.offsetX; 42 int x = event.offset.x;
43 int y = event.offsetY - 40; 43 int y = event.offset.y - 40;
44 if (( y < 0) || (x >= width)) { 44 if (( y < 0) || (x >= width)) {
45 return; 45 return;
46 } 46 }
47 ctx.fillStyle = getHexString(getColorIndex(x, y)); 47 ctx.fillStyle = getHexString(getColorIndex(x, y));
48 ctx.fillRect(0, 0, width/2, 30); 48 ctx.fillRect(0, 0, width/2, 30);
49 } 49 }
50 50
51 void onMouseDown(MouseEvent event) { 51 void onMouseDown(MouseEvent event) {
52 Element elt = event.target; 52 Element elt = event.target;
53 event.cancelBubble = true; 53 event.cancelBubble = true;
54 int x = event.offsetX; 54 int x = event.offset.x;
55 int y = event.offsetY - 40; 55 int y = event.offset.y - 40;
56 if ((y < 0) || (x >= width)) { 56 if ((y < 0) || (x >= width)) {
57 return; 57 return;
58 } 58 }
59 selectedColor = getHexString(getColorIndex(x, y)); 59 selectedColor = getHexString(getColorIndex(x, y));
60 } 60 }
61 61
62 /** 62 /**
63 * Adds a [PickerListener] to receive updates. 63 * Adds a [PickerListener] to receive updates.
64 */ 64 */
65 void addListener(PickerListener listener) { 65 void addListener(PickerListener listener) {
(...skipping 44 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/solar3d/web/solar.dart ('k') | samples/swarm/swarm_ui_lib/touch/Geometry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698