Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/graphics/lineargradient.js
2868 views
1
// Copyright 2007 The Closure Library Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS-IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
16
/**
17
* @fileoverview Represents a gradient to be used with a Graphics implementor.
18
* @author [email protected] (Erik Arvidsson)
19
*/
20
21
22
goog.provide('goog.graphics.LinearGradient');
23
24
25
goog.require('goog.asserts');
26
goog.require('goog.graphics.Fill');
27
28
29
30
/**
31
* Creates an immutable linear gradient fill object.
32
*
33
* @param {number} x1 Start X position of the gradient.
34
* @param {number} y1 Start Y position of the gradient.
35
* @param {number} x2 End X position of the gradient.
36
* @param {number} y2 End Y position of the gradient.
37
* @param {string} color1 Start color of the gradient.
38
* @param {string} color2 End color of the gradient.
39
* @param {?number=} opt_opacity1 Start opacity of the gradient, both or neither
40
* of opt_opacity1 and opt_opacity2 have to be set.
41
* @param {?number=} opt_opacity2 End opacity of the gradient.
42
* @constructor
43
* @extends {goog.graphics.Fill}
44
* @deprecated goog.graphics is deprecated. It existed to abstract over browser
45
* differences before the canvas tag was widely supported. See
46
* http://en.wikipedia.org/wiki/Canvas_element for details.
47
* @final
48
*/
49
goog.graphics.LinearGradient = function(
50
x1, y1, x2, y2, color1, color2, opt_opacity1, opt_opacity2) {
51
/**
52
* Start X position of the gradient.
53
* @type {number}
54
* @private
55
*/
56
this.x1_ = x1;
57
58
/**
59
* Start Y position of the gradient.
60
* @type {number}
61
* @private
62
*/
63
this.y1_ = y1;
64
65
/**
66
* End X position of the gradient.
67
* @type {number}
68
* @private
69
*/
70
this.x2_ = x2;
71
72
/**
73
* End Y position of the gradient.
74
* @type {number}
75
* @private
76
*/
77
this.y2_ = y2;
78
79
/**
80
* Start color of the gradient.
81
* @type {string}
82
* @private
83
*/
84
this.color1_ = color1;
85
86
/**
87
* End color of the gradient.
88
* @type {string}
89
* @private
90
*/
91
this.color2_ = color2;
92
93
goog.asserts.assert(
94
goog.isNumber(opt_opacity1) == goog.isNumber(opt_opacity2),
95
'Both or neither of opt_opacity1 and opt_opacity2 have to be set.');
96
97
/**
98
* Start opacity of the gradient.
99
* @type {?number}
100
* @private
101
*/
102
this.opacity1_ = goog.isDef(opt_opacity1) ? opt_opacity1 : null;
103
104
/**
105
* End opacity of the gradient.
106
* @type {?number}
107
* @private
108
*/
109
this.opacity2_ = goog.isDef(opt_opacity2) ? opt_opacity2 : null;
110
};
111
goog.inherits(goog.graphics.LinearGradient, goog.graphics.Fill);
112
113
114
/**
115
* @return {number} The start X position of the gradient.
116
*/
117
goog.graphics.LinearGradient.prototype.getX1 = function() {
118
return this.x1_;
119
};
120
121
122
/**
123
* @return {number} The start Y position of the gradient.
124
*/
125
goog.graphics.LinearGradient.prototype.getY1 = function() {
126
return this.y1_;
127
};
128
129
130
/**
131
* @return {number} The end X position of the gradient.
132
*/
133
goog.graphics.LinearGradient.prototype.getX2 = function() {
134
return this.x2_;
135
};
136
137
138
/**
139
* @return {number} The end Y position of the gradient.
140
*/
141
goog.graphics.LinearGradient.prototype.getY2 = function() {
142
return this.y2_;
143
};
144
145
146
/**
147
* @override
148
*/
149
goog.graphics.LinearGradient.prototype.getColor1 = function() {
150
return this.color1_;
151
};
152
153
154
/**
155
* @override
156
*/
157
goog.graphics.LinearGradient.prototype.getColor2 = function() {
158
return this.color2_;
159
};
160
161
162
/**
163
* @return {?number} The start opacity of the gradient.
164
*/
165
goog.graphics.LinearGradient.prototype.getOpacity1 = function() {
166
return this.opacity1_;
167
};
168
169
170
/**
171
* @return {?number} The end opacity of the gradient.
172
*/
173
goog.graphics.LinearGradient.prototype.getOpacity2 = function() {
174
return this.opacity2_;
175
};
176
177