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

Side by Side Diff: sky/engine/core/painting/Gradient.dart

Issue 1170963003: Sky: Add a DartConverterEnum and use that for all our enum needs. (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: 360 no scope 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 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 }
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