グラデーション塗りの練習。
またまた円を書く。
以下の本を読みながらグラデ塗りの練習中です。
サンプルはこちら。
以下、ソースです。
package
{
import flash.display.BlendMode;
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.SpreadMethod;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageQuality;
import flash.display.StageScaleMode;
import flash.filters.DropShadowFilter;
import flash.geom.Matrix;
public class main extends Sprite
{
public function main()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.quality = StageQuality.HIGH;
stage.frameRate = 40;
init();
}
private function init():void
{
// 全部をのせるコンテナ
var container:Sprite = addChild(new Sprite) as Sprite;
container.x = container.y = 250;
container.scaleY = 0.7;
// 外枠をのせるコンテナ
var frame:Sprite = container.addChild(new Sprite) as Sprite;
frame.rotation = 60;
frame.filters = [new DropShadowFilter(4,45,0x0, 0.5, 6, 6,1,3)];
// 外枠を描く
var shape:Shape = frame.addChild(new Shape) as Shape;
var g:Graphics = shape.graphics;
var matrix:Matrix = new Matrix;
matrix.createGradientBox(400, 400, 0, -200, -200);
g.beginGradientFill(GradientType.RADIAL, [0xffffff, 0xffffff, 0x7a8f8f], [0.8, 0.8, 0.8], [0, 200, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 200);
g.endFill();
shape = frame.addChild(new Shape) as Shape;
g = shape.graphics;
matrix.createGradientBox(280, 280, 0, -140, -140);
g.beginGradientFill(GradientType.LINEAR, [0xffffff, 0xffffff, 0xffffff, 0xffffff], [1, 0.3, 0.2, 0], [0, 60, 80, 100], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 140);
g.endFill();
shape.scaleX = 0.7;
shape.x = -90;
shape = frame.addChild(new Shape) as Shape;
g = shape.graphics;
matrix.createGradientBox(280, 280, 180, -140, -140);
g.beginGradientFill(GradientType.LINEAR, [0xffffff, 0xffffff, 0xffffff, 0xffffff], [1, 0.3, 0.2, 0], [0, 60, 80, 100], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 140);
g.endFill();
shape.scaleX = 0.7;
shape.alpha = 0.2;
shape.x = 90;
shape = frame.addChild(new Shape) as Shape;
g = shape.graphics;
matrix.createGradientBox(320, 320, 20*Math.PI/180, -160, -160);
g.beginGradientFill(GradientType.LINEAR, [0x666666,0x000000], [1,1], [0, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 160);
g.endFill();
// 青い球体をのせるコンテナ
var blue_circle:Sprite = container.addChild(new Sprite) as Sprite;
blue_circle.rotation = -30;
g = blue_circle.graphics;
g.beginFill(0xffffff, 1);
g.drawCircle(0,0,155);
g.endFill();
// 円を描く
shape = blue_circle.addChild(new Shape) as Shape;
shape.blendMode = BlendMode.MULTIPLY;
g = shape.graphics;
matrix.createGradientBox(310, 310, (120)*Math.PI/180, -155, -155);
g.beginGradientFill(GradientType.LINEAR, [0x80ccff, 0x00a6ff, 0x1a6680], [1, 1, 1], [0, 127.5, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 155);
g.endFill();
shape = blue_circle.addChild(new Shape) as Shape;
shape.blendMode = BlendMode.MULTIPLY;
g = shape.graphics;
matrix.createGradientBox(310, 310, (120)*Math.PI/180, -155, -155);
g.beginGradientFill(GradientType.LINEAR, [0x80ccff, 0x00a6ff, 0x1a6680], [1, 1, 1], [0, 127.5, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 155);
g.endFill();
shape = blue_circle.addChild(new Shape) as Shape;
shape.blendMode = BlendMode.MULTIPLY;
g = shape.graphics;
matrix.createGradientBox(310, 310, (75)*Math.PI/180, -155, -155);
g.beginGradientFill(GradientType.LINEAR, [0x80ccff, 0x00a6ff, 0x1a6680], [1, 1, 1], [0, 127.5, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 155);
g.endFill();
shape = blue_circle.addChild(new Shape) as Shape;
shape.blendMode = BlendMode.MULTIPLY;
g = shape.graphics;
matrix.createGradientBox(310, 310, (20)*Math.PI/180, -155, -155);
g.beginGradientFill(GradientType.LINEAR, [0x80ccff, 0x00a6ff, 0x1a6680], [1, 1, 1], [0, 127.5, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 155);
g.endFill();
shape = blue_circle.addChild(new Shape) as Shape;
shape.blendMode = BlendMode.MULTIPLY;
g = shape.graphics;
matrix.createGradientBox(310, 310, (-5)*Math.PI/180, -155, -155);
g.beginGradientFill(GradientType.LINEAR, [0x80ccff, 0x00a6ff, 0x1a6680], [1, 1, 1], [0, 127.5, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 155);
g.endFill();
shape = blue_circle.addChild(new Shape) as Shape;
g = shape.graphics;
matrix.createGradientBox(310, 310, (-95)*Math.PI/180, -155, -155);
g.beginGradientFill(GradientType.LINEAR, [0xffffff, 0xffffff, 0xffffff], [0, 0.3, 0.7], [0, 216.75, 255], matrix, SpreadMethod.PAD);
g.drawCircle(0, 0, 155);
g.endFill();
shape.scaleX = 0.69;
shape.scaleY = 0.56;
shape.y = -60;
}
}
}
