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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Extends the generated _Gradient interface via the PrivateDart attribute. 7 // Extends the generated _Gradient interface via the PrivateDart attribute.
8 class Gradient extends _Gradient { 8 class Gradient extends _Gradient {
9 // TODO(mpcomplete): Support other gradient types.
10 // TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead? 9 // TODO(mpcomplete): Maybe pass a list of (color, colorStop) pairs instead?
11 Gradient.Linear(List<Point> endPoints, 10 Gradient.Linear(List<Point> endPoints,
12 List<Color> colors, 11 List<Color> colors,
13 List<double> colorStops) 12 List<double> colorStops)
14 : super(0, endPoints, colors, _validate(colorStops, colors)); 13 : super() {
14 if (endPoints == null || endPoints.length != 2)
15 throw new ArgumentError("Expected exactly 2 [endPoints].");
16 validateColorStops(colors, colorStops);
17 this._initLinear(endPoints, colors, colorStops);
18 }
15 19
16 // TODO(mpcomplete): Figure out a good way to validate arguments. 20 Gradient.Radial(Point center,
17 static List<double> _validate(colorStops, colors) { 21 double radius,
22 List<Color> colors,
23 List<double> colorStops)
24 : super() {
25 validateColorStops(colors, colorStops);
26 this._initRadial(center, radius, colors, colorStops);
27 }
28
29 void validateColorStops(List<Color> colors, List<double> colorStops) {
18 if (colorStops != null && colors.length != colorStops.length) { 30 if (colorStops != null && colors.length != colorStops.length) {
19 throw new ArgumentError( 31 throw new ArgumentError(
20 "[colors] and [colorStops] parameters must be equal length."); 32 "[colors] and [colorStops] parameters must be equal length.");
21 } 33 }
22 return colorStops;
23 } 34 }
24 } 35 }
OLDNEW
« 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