グラデーションの練習
グラデーション表示させまくる
* わかりずらいので後で改良する
/**
* Copyright yasai ( http://wonderfl.net/user/yasai )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/RfnM
*/
/**
* グラデーション表示させまくる
* わかりずらいので後で改良する
*/
package {
import adobe.utils.CustomActions;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.GradientType;
import flash.geom.Matrix;
public class FlashTest extends Sprite {
private var _x:Number = 0;
private var _y:Number = 0;
private const NUM:int = 18;
private const H:Number = 465 / NUM;
private var color1:uint = 0x000000;
private var color2:uint = 0xFFFFFF;
private var _w:Number = 465 / NUM;
private var _h:Number = H
private var ratio:Number = 255 / NUM;
public function FlashTest() {
// write as3 code here..
drawGradient(GradientType.LINEAR, true);
drawGradient(GradientType.LINEAR, false, true);
drawGradient(GradientType.LINEAR, false, true, "pad", "linearRGB");
drawGradient(GradientType.LINEAR, false, true, "reflect");
drawGradient(GradientType.LINEAR, false, true, "reflect", "linearRGB");
drawGradient(GradientType.LINEAR, false, true, "repeat");
drawGradient(GradientType.LINEAR, false, true, "repeat", "linearRGB");
drawGradient(GradientType.RADIAL, true);
drawGradient(GradientType.RADIAL, false, true);
drawGradient(GradientType.RADIAL, false, true, "pad", "linearRGB");
drawGradient(GradientType.RADIAL, false, true, "reflect");
drawGradient(GradientType.RADIAL, false, true, "reflect", "linearRGB");
drawGradient(GradientType.RADIAL, false, true, "repeat");
drawGradient(GradientType.RADIAL, false, true, "repeat", "linearRGB");
drawGradient(GradientType.RADIAL, false, false, "pad", "rgb", true);
drawGradient(GradientType.RADIAL, false, false, "pad", "linearRGB", true);
drawGradient(GradientType.RADIAL, false, false, "repeat", "rgb", true);
drawGradient(GradientType.RADIAL, false, false, "repeat", "linearRGB", true);
}
private function drawGradient(type:String, ratiofla:Boolean = false, rotate:Boolean = false, spred:String = "pad", interpolation:String = "rgb", focalpoint:Boolean = false):void {
for (var i:int = 1; i <= NUM; i++) {
var s:Shape = new Shape();
var c:Array = [color1, color2];
var a:Array = [1, 1];
var r:Array = [0, (ratiofla == true) ? ratio * i : 255];
var m:Matrix = new Matrix();
m.createGradientBox(_w, _h);
if (rotate == true) m.rotate(Math.PI / i);
var focalpointratio:Number = 0;
if (focalpoint == true) focalpointratio = (1 / NUM) * i;
s.graphics.beginGradientFill(type, c, a, r, m, spred, interpolation, focalpointratio);
s.graphics.drawRect(0, 0, _w, _h);
s.graphics.endFill();
s.x = _x;
s.y = _y;
addChild(s);
_x += s.width;
}
initXY();
}
private function initXY():void {
_x = 0;
_y += H;
}
}
}