Index: sky/engine/core/painting/Gradient.dart |
diff --git a/sky/engine/core/painting/Gradient.dart b/sky/engine/core/painting/Gradient.dart |
index 138072b9dc52d414479a619b9434a1e81a2526cb..58381812fd72f42ef6709daa89458fcfab11d5eb 100644 |
--- a/sky/engine/core/painting/Gradient.dart |
+++ b/sky/engine/core/painting/Gradient.dart |
@@ -6,19 +6,30 @@ part of dart.sky; |
// Extends the generated _Gradient interface via the PrivateDart attribute. |
class Gradient extends _Gradient { |
- // TODO(mpcomplete): Support other gradient types. |
// TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead? |
Gradient.Linear(List<Point> endPoints, |
List<Color> colors, |
List<double> colorStops) |
- : super(0, endPoints, colors, _validate(colorStops, colors)); |
+ : super() { |
+ if (endPoints == null || endPoints.length != 2) |
+ throw new ArgumentError("Expected exactly 2 [endPoints]."); |
+ validateColorStops(colors, colorStops); |
+ this._initLinear(endPoints, colors, colorStops); |
+ } |
+ |
+ Gradient.Radial(Point center, |
+ double radius, |
+ List<Color> colors, |
+ List<double> colorStops) |
+ : super() { |
+ validateColorStops(colors, colorStops); |
+ this._initRadial(center, radius, colors, colorStops); |
+ } |
- // TODO(mpcomplete): Figure out a good way to validate arguments. |
- static List<double> _validate(colorStops, colors) { |
+ void validateColorStops(List<Color> colors, List<double> colorStops) { |
if (colorStops != null && colors.length != colorStops.length) { |
throw new ArgumentError( |
"[colors] and [colorStops] parameters must be equal length."); |
} |
- return colorStops; |
} |
} |