| 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 // Extends the generated _Gradient interface via the CustomDart attribute. | 5 part of dart.sky; |
| 6 | 6 |
| 7 // Extends the generated _Gradient interface via the PrivateDart attribute. |
| 7 class Gradient extends _Gradient { | 8 class Gradient extends _Gradient { |
| 8 // TODO(mpcomplete): Support other gradient types. | 9 // TODO(mpcomplete): Support other gradient types. |
| 9 // TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead? | 10 // TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead? |
| 10 Gradient.Linear(List<Point> endPoints, | 11 Gradient.Linear(List<Point> endPoints, |
| 11 List<Color> colors, | 12 List<Color> colors, |
| 12 List<double> colorStops) | 13 List<double> colorStops) |
| 13 : super(0, endPoints, colors, _validate(colorStops, colors)); | 14 : super(0, endPoints, colors, _validate(colorStops, colors)); |
| 14 | 15 |
| 15 // TODO(mpcomplete): Figure out a good way to validate arguments. | 16 // TODO(mpcomplete): Figure out a good way to validate arguments. |
| 16 static List<double> _validate(colorStops, colors) { | 17 static List<double> _validate(colorStops, colors) { |
| 17 if (colorStops != null && colors.length != colorStops.length) { | 18 if (colorStops != null && colors.length != colorStops.length) { |
| 18 throw new ArgumentError( | 19 throw new ArgumentError( |
| 19 "[colors] and [colorStops] parameters must be equal length."); | 20 "[colors] and [colorStops] parameters must be equal length."); |
| 20 } | 21 } |
| 21 return colorStops; | 22 return colorStops; |
| 22 } | 23 } |
| 23 } | 24 } |
| OLD | NEW |