OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import 'dart:math' as math; | 5 import 'dart:math' as math; |
6 import 'dart:sky' as sky; | 6 import 'dart:sky' as sky; |
7 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; | 7 import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; |
8 | 8 |
9 import 'shadows.dart'; | 9 import 'shadows.dart'; |
10 | 10 |
11 class BorderSide { | 11 class BorderSide { |
12 const BorderSide({ | 12 const BorderSide({ |
13 this.color: const Color(0xFF000000), | 13 this.color: const Color(0xFF000000), |
14 this.width: 1.0 | 14 this.width: 1.0 |
15 }); | 15 }); |
16 final Color color; | 16 final Color color; |
17 final double width; | 17 final double width; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 class BoxShadow { | 60 class BoxShadow { |
61 const BoxShadow({ | 61 const BoxShadow({ |
62 this.color, | 62 this.color, |
63 this.offset, | 63 this.offset, |
64 this.blur | 64 this.blur |
65 }); | 65 }); |
66 | 66 |
67 final Color color; | 67 final Color color; |
68 final Size offset; | 68 final Offset offset; |
69 final double blur; | 69 final double blur; |
70 | 70 |
71 String toString() => 'BoxShadow($color, $offset, $blur)'; | 71 String toString() => 'BoxShadow($color, $offset, $blur)'; |
72 } | 72 } |
73 | 73 |
74 abstract class Gradient { | 74 abstract class Gradient { |
75 sky.Shader createShader(); | 75 sky.Shader createShader(); |
76 } | 76 } |
77 | 77 |
78 class LinearGradient extends Gradient { | 78 class LinearGradient extends Gradient { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 void paint(sky.Canvas canvas, Rect rect) { | 203 void paint(sky.Canvas canvas, Rect rect) { |
204 if (_decoration.backgroundColor != null || _decoration.boxShadow != null || | 204 if (_decoration.backgroundColor != null || _decoration.boxShadow != null || |
205 _decoration.gradient != null) { | 205 _decoration.gradient != null) { |
206 switch (_decoration.shape) { | 206 switch (_decoration.shape) { |
207 case Shape.circle: | 207 case Shape.circle: |
208 assert(_decoration.borderRadius == null); | 208 assert(_decoration.borderRadius == null); |
209 Point center = rect.center; | 209 Point center = rect.center; |
210 Size size = rect.size; | 210 Size size = rect.size; |
211 double radius = math.min(size.width, size.height) / 2.0; | 211 double radius = math.min(size.width, size.height) / 2.0; |
212 canvas.drawCircle(center.x, center.y, radius, _backgroundPaint); | 212 canvas.drawCircle(center, radius, _backgroundPaint); |
213 break; | 213 break; |
214 case Shape.rectangle: | 214 case Shape.rectangle: |
215 if (_decoration.borderRadius == null) | 215 if (_decoration.borderRadius == null) |
216 canvas.drawRect(rect, _backgroundPaint); | 216 canvas.drawRect(rect, _backgroundPaint); |
217 else | 217 else |
218 canvas.drawRRect(new sky.RRect()..setRectXY(rect, _decoration.border
Radius, _decoration.borderRadius), _backgroundPaint); | 218 canvas.drawRRect(new sky.RRect()..setRectXY(rect, _decoration.border
Radius, _decoration.borderRadius), _backgroundPaint); |
219 break; | 219 break; |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 path = new Path(); | 263 path = new Path(); |
264 path.moveTo(rect.left, rect.bottom); | 264 path.moveTo(rect.left, rect.bottom); |
265 path.lineTo(rect.left + _decoration.border.left.width, rect.bottom - _deco
ration.border.bottom.width); | 265 path.lineTo(rect.left + _decoration.border.left.width, rect.bottom - _deco
ration.border.bottom.width); |
266 path.lineTo(rect.left + _decoration.border.left.width, rect.top + _decorat
ion.border.top.width); | 266 path.lineTo(rect.left + _decoration.border.left.width, rect.top + _decorat
ion.border.top.width); |
267 path.lineTo(rect.left, rect.top); | 267 path.lineTo(rect.left, rect.top); |
268 path.close(); | 268 path.close(); |
269 canvas.drawPath(path, paint); | 269 canvas.drawPath(path, paint); |
270 } | 270 } |
271 } | 271 } |
272 } | 272 } |
OLD | NEW |