Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: sky/engine/core/painting/Gradient.dart

Issue 1169863002: Sky: Added radial gradients. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/painting/CanvasGradient.cpp ('k') | sky/engine/core/painting/Gradient.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
}
« no previous file with comments | « sky/engine/core/painting/CanvasGradient.cpp ('k') | sky/engine/core/painting/Gradient.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698