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

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

Issue 1152963009: Add support for linear gradients, implemented as skia shaders. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: . 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
Index: sky/engine/core/painting/Gradient.dart
diff --git a/sky/engine/core/painting/Gradient.dart b/sky/engine/core/painting/Gradient.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2fa52470b78b32a07d4e0490517bfe4b01bdd28c
--- /dev/null
+++ b/sky/engine/core/painting/Gradient.dart
@@ -0,0 +1,23 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Extends the generated _Gradient interface via the CustomDart attribute.
+
+class Gradient extends _Gradient {
+ // TODO(mpcomplete): Support other gradient types.
+ // TODO(mpcomplete): Should we pas a list of (color, colorStop) pairs instead?
eseidel 2015/06/08 17:26:57 pas -> pass
Matt Perry 2015/06/08 17:43:53 Done.
+ Gradient.Linear(List<Point> endPoints,
+ List<Color> colors,
+ List<double> colorStops)
+ : super(0, endPoints, colors, _validate(colorStops, colors));
+
+ // TODO(mpcomplete): Figure out a good way to validate arguments.
+ static List<double> _validate(colorStops, colors) {
+ if (colorStops != null && colors.length != colorStops.length) {
+ throw new ArgumentError(
+ "[colors] and [colorStops] parameters must be equal length.");
+ }
+ return colorStops;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698