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