グラデーションの練習
♥0 |
Line 49 |
Modified 2010-06-22 23:31:47 |
MIT License
archived:2017-03-20 13:26:20
ActionScript3 source code
/**
* Copyright hacker_szoe51ih ( http://wonderfl.net/user/hacker_szoe51ih )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/4TLR
*/
package {
import flash.display.*;
import flash.events.*;
[SWF(width="465",height="465",backgroundColor="0xffffff",fps="45")]
import flash.display.Sprite;
public class FlashTest extends Sprite {
public var myBall:Ball;
public var centerX:Number=stage.stageWidth/2;
public var centerY:Number=stage.stageHeight/2;
public function FlashTest() {
init();
}
public function init():void{
myBall=new Ball(0xccccff,0x2255ff,0x1111ff,50);
addChild(myBall);
myBall.x=centerX;
myBall.y=centerY;
}
}
}
import flash.display.*;
import flash.geom.Matrix;
class Ball extends Sprite{
public var type:String;
public var colors:Array;
public var alphas:Array;
public var rations:Array;
public var spread:String;
public var interpolation:String;
public var focalPoint:Number;
public var mtx:Matrix;
public function Ball(color1:uint,color2:uint,lineColor:uint,r:Number){
//グラデーションのパラメーターを作る
//引数1
type=GradientType.RADIAL;
//引数2
colors=[color1,color2];
//引数3
alphas=[1,1]
//引数4
rations=[0,255];
//引数5
mtx=new Matrix();
mtx.createGradientBox(2*r,2*r,0,0,0);//幅、高さ、方向を指定する角度、水平移動ピクセル数、垂直移動ピクセル数
mtx.translate(-r,-r);//グラデーションの開始位置を中心にもってくる
mtx.rotate(Math.PI/4);
//引数6
spread=SpreadMethod.PAD;
//引数7
interpolation="rgb"
//引数8
focalPoint=0//グラデーションの焦点の位置
graphics.beginGradientFill(type,colors,alphas,rations,mtx,spread,interpolation,focalPoint);
//図形を描く
graphics.lineStyle(1,lineColor);
graphics.drawCircle(0,0,r);
graphics.endFill();
}
}