forked from: gradation
/**
* Copyright yuugurenote ( http://wonderfl.net/user/yuugurenote )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hLIw
*/
// forked from Scmiz's gradation
package {
import flash.display.Graphics;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
drawBG(
this.graphics,
0, 100, 255,
150, 50, 50
);
}
private function drawBG(g:Graphics, topColorR:uint, topColorG:uint, topColorB:uint, bottomColorR:uint, bottomColorG:uint, bottomColorB:uint):void {
g.clear();
for (var index:uint = 0; index < 465; ++index) {
var ratio:Number = Number(index) / 465;
var ratioR:Number = 1.0 - ratio;
var cr:uint = (topColorR * ratioR) + (bottomColorR * ratio);
var cg:uint = (topColorG * ratioR) + (bottomColorG * ratio);
var cb:uint = (topColorB * ratioR) + (bottomColorB * ratio);
var color:uint = (cr << 16) + (cg << 8) + (cb << 0);
g.beginFill(color);
g.drawRect(0, 1 * index, 465, 1);
g.endFill();
}
}
}
}