| 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 part of dart.sky; | 5 part of dart.sky; |
| 6 | 6 |
| 7 enum TileMode { | 7 enum TileMode { |
| 8 clamp, | 8 clamp, |
| 9 repeated, | 9 repeated, |
| 10 mirror | 10 mirror |
| 11 } | 11 } |
| 12 | 12 |
| 13 // Extends the generated _Gradient interface via the PrivateDart attribute. | 13 // Extends the generated _Gradient interface via the PrivateDart attribute. |
| 14 class Gradient extends _Gradient { | 14 class Gradient extends _Gradient { |
| 15 // TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead? | 15 // TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead? |
| 16 Gradient.Linear(List<Point> endPoints, | 16 Gradient.Linear(List<Point> endPoints, |
| 17 List<Color> colors, | 17 List<Color> colors, |
| 18 List<double> colorStops, | 18 List<double> colorStops, |
| 19 [TileMode tileMode = TileMode.clamp]) | 19 [TileMode tileMode = TileMode.clamp]) |
| 20 : super() { | 20 : super() { |
| 21 if (endPoints == null || endPoints.length != 2) | 21 if (endPoints == null || endPoints.length != 2) |
| 22 throw new ArgumentError("Expected exactly 2 [endPoints]."); | 22 throw new ArgumentError("Expected exactly 2 [endPoints]."); |
| 23 validateColorStops(colors, colorStops); | 23 validateColorStops(colors, colorStops); |
| 24 this._initLinear(endPoints, colors, colorStops, tileMode.index); | 24 this._initLinear(endPoints, colors, colorStops, tileMode); |
| 25 } | 25 } |
| 26 | 26 |
| 27 Gradient.Radial(Point center, | 27 Gradient.Radial(Point center, |
| 28 double radius, | 28 double radius, |
| 29 List<Color> colors, | 29 List<Color> colors, |
| 30 List<double> colorStops, | 30 List<double> colorStops, |
| 31 [TileMode tileMode = TileMode.clamp]) | 31 [TileMode tileMode = TileMode.clamp]) |
| 32 : super() { | 32 : super() { |
| 33 validateColorStops(colors, colorStops); | 33 validateColorStops(colors, colorStops); |
| 34 this._initRadial(center, radius, colors, colorStops, tileMode.index); | 34 this._initRadial(center, radius, colors, colorStops, tileMode); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void validateColorStops(List<Color> colors, List<double> colorStops) { | 37 void validateColorStops(List<Color> colors, List<double> colorStops) { |
| 38 if (colorStops != null && colors.length != colorStops.length) { | 38 if (colorStops != null && colors.length != colorStops.length) { |
| 39 throw new ArgumentError( | 39 throw new ArgumentError( |
| 40 "[colors] and [colorStops] parameters must be equal length."); | 40 "[colors] and [colorStops] parameters must be equal length."); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 } | 43 } |
| OLD | NEW |