1 /**
  2  * The MIT License (MIT)
  3  *
  4  * Copyright (c) 2016 DeNA Co., Ltd.
  5  *
  6  * Permission is hereby granted, free of charge, to any person obtaining a copy
  7  * of this software and associated documentation files (the "Software"), to deal
  8  * in the Software without restriction, including without limitation the rights
  9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10  * copies of the Software, and to permit persons to whom the Software is
 11  * furnished to do so, subject to the following conditions:
 12  *
 13  * The above copyright notice and this permission notice shall be included in
 14  * all copies or substantial portions of the Software.
 15  *
 16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 22  * SOFTWARE.
 23  */
 24 
 25 /// <reference path="base.js"/>
 26 /// <reference path="object.js"/>
 27 
 28 /**
 29  * A class representing an ARGB color.
 30  * @param {number} red
 31  * @param {number} green
 32  * @param {number} blue
 33  * @param {number} alpha
 34  * @extends {createjs.Object}
 35  * @constructor
 36  */
 37 createjs.Color = function(red, green, blue, alpha) {
 38   /// <param type="number" name="red"/>
 39   /// <param type="number" name="green"/>
 40   /// <param type="number" name="blue"/>
 41   /// <param type="number" name="alpha"/>
 42   createjs.Object.call(this);
 43 
 44   /**
 45    * The red component.
 46    * @type {number}
 47    */
 48   this.red_ = red;
 49 
 50   /**
 51    * The green component.
 52    * @type {number}
 53    */
 54   this.green_ = green;
 55 
 56   /**
 57    * The blue component.
 58    * @type {number}
 59    */
 60   this.blue_ = blue;
 61 
 62   /**
 63    * The alpha component.
 64    * @type {number}
 65    */
 66   this.alpha_ = alpha;
 67 };
 68 createjs.inherits('Color', createjs.Color, createjs.Object);
 69 
 70 /**
 71  * Returns the red component of this color.
 72  * @return {number}
 73  * @const
 74  */
 75 createjs.Color.prototype.getRed = function() {
 76   /// <returns type="number"/>
 77   return this.red_;
 78 };
 79 
 80 /**
 81  * Returns the green component of this color.
 82  * @return {number}
 83  * @const
 84  */
 85 createjs.Color.prototype.getGreen = function() {
 86   /// <returns type="number"/>
 87   return this.green_;
 88 };
 89 
 90 /**
 91  * Returns the blue component of this color.
 92  * @return {number}
 93  * @const
 94  */
 95 createjs.Color.prototype.getBlue = function() {
 96   /// <returns type="number"/>
 97   return this.blue_;
 98 };
 99 
100 /**
101  * Returns the alpha component of this color.
102  * @return {number}
103  * @const
104  */
105 createjs.Color.prototype.getAlpha = function() {
106   /// <returns type="number"/>
107   return this.alpha_;
108 };
109 
110 /**
111  * Copies the specified color to this color.
112  * @param {createjs.Color} color
113  * @const
114  */
115 createjs.Color.prototype.copyColor = function(color) {
116   /// <param type="createjs.Color" name="color"/>
117   this.red_ = color.red_;
118   this.green_ = color.green_;
119   this.blue_ = color.blue_;
120   this.alpha_ = color.alpha_;
121 };
122 
123 /**
124  * Adds the specified color with this color.
125  * @param {createjs.Color} color
126  * @const
127  */
128 createjs.Color.prototype.addColor = function(color) {
129   /// <param type="createjs.Color" name="color"/>
130   this.red_ += color.red_;
131   this.green_ += color.green_;
132   this.blue_ += color.blue_;
133   this.alpha_ += color.alpha_;
134 };
135 
136 /**
137  * Multiplies the specified color with this color.
138  * @param {createjs.Color} color
139  * @const
140  */
141 createjs.Color.prototype.multiplyColor = function(color) {
142   /// <param type="createjs.Color" name="color"/>
143   this.red_ *= color.red_;
144   this.green_ *= color.green_;
145   this.blue_ *= color.blue_;
146   this.alpha_ *= color.alpha_;
147 };
148