Path: blob/trunk/third_party/closure/goog/graphics/lineargradient.js
2868 views
// Copyright 2007 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.131415/**16* @fileoverview Represents a gradient to be used with a Graphics implementor.17* @author [email protected] (Erik Arvidsson)18*/192021goog.provide('goog.graphics.LinearGradient');222324goog.require('goog.asserts');25goog.require('goog.graphics.Fill');26272829/**30* Creates an immutable linear gradient fill object.31*32* @param {number} x1 Start X position of the gradient.33* @param {number} y1 Start Y position of the gradient.34* @param {number} x2 End X position of the gradient.35* @param {number} y2 End Y position of the gradient.36* @param {string} color1 Start color of the gradient.37* @param {string} color2 End color of the gradient.38* @param {?number=} opt_opacity1 Start opacity of the gradient, both or neither39* of opt_opacity1 and opt_opacity2 have to be set.40* @param {?number=} opt_opacity2 End opacity of the gradient.41* @constructor42* @extends {goog.graphics.Fill}43* @deprecated goog.graphics is deprecated. It existed to abstract over browser44* differences before the canvas tag was widely supported. See45* http://en.wikipedia.org/wiki/Canvas_element for details.46* @final47*/48goog.graphics.LinearGradient = function(49x1, y1, x2, y2, color1, color2, opt_opacity1, opt_opacity2) {50/**51* Start X position of the gradient.52* @type {number}53* @private54*/55this.x1_ = x1;5657/**58* Start Y position of the gradient.59* @type {number}60* @private61*/62this.y1_ = y1;6364/**65* End X position of the gradient.66* @type {number}67* @private68*/69this.x2_ = x2;7071/**72* End Y position of the gradient.73* @type {number}74* @private75*/76this.y2_ = y2;7778/**79* Start color of the gradient.80* @type {string}81* @private82*/83this.color1_ = color1;8485/**86* End color of the gradient.87* @type {string}88* @private89*/90this.color2_ = color2;9192goog.asserts.assert(93goog.isNumber(opt_opacity1) == goog.isNumber(opt_opacity2),94'Both or neither of opt_opacity1 and opt_opacity2 have to be set.');9596/**97* Start opacity of the gradient.98* @type {?number}99* @private100*/101this.opacity1_ = goog.isDef(opt_opacity1) ? opt_opacity1 : null;102103/**104* End opacity of the gradient.105* @type {?number}106* @private107*/108this.opacity2_ = goog.isDef(opt_opacity2) ? opt_opacity2 : null;109};110goog.inherits(goog.graphics.LinearGradient, goog.graphics.Fill);111112113/**114* @return {number} The start X position of the gradient.115*/116goog.graphics.LinearGradient.prototype.getX1 = function() {117return this.x1_;118};119120121/**122* @return {number} The start Y position of the gradient.123*/124goog.graphics.LinearGradient.prototype.getY1 = function() {125return this.y1_;126};127128129/**130* @return {number} The end X position of the gradient.131*/132goog.graphics.LinearGradient.prototype.getX2 = function() {133return this.x2_;134};135136137/**138* @return {number} The end Y position of the gradient.139*/140goog.graphics.LinearGradient.prototype.getY2 = function() {141return this.y2_;142};143144145/**146* @override147*/148goog.graphics.LinearGradient.prototype.getColor1 = function() {149return this.color1_;150};151152153/**154* @override155*/156goog.graphics.LinearGradient.prototype.getColor2 = function() {157return this.color2_;158};159160161/**162* @return {?number} The start opacity of the gradient.163*/164goog.graphics.LinearGradient.prototype.getOpacity1 = function() {165return this.opacity1_;166};167168169/**170* @return {?number} The end opacity of the gradient.171*/172goog.graphics.LinearGradient.prototype.getOpacity2 = function() {173return this.opacity2_;174};175176177