回転する疑似曲面 (3)
//////////////////////////////////////////////////////////////////////////////
[AS3.0] 回転する疑似曲面
http://www.project-nya.jp/modules/weblog/details.php?blog_id=1045
Flash Memo for Designers: ねじれて回転するドット
http://casualplay.net/blog/2006/02/post_4.html
//////////////////////////////////////////////////////////////////////////////
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8dfT
*/
////////////////////////////////////////////////////////////////////////////////
// [AS3.0] 回転する疑似曲面
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1045
// Flash Memo for Designers: ねじれて回転するドット
// http://casualplay.net/blog/2006/02/post_4.html
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
[SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]
public class Main extends Sprite {
private var twist:DotTwist;
public function Main() {
//Wonderfl.disable_capture();
Wonderfl.capture_delay(4);
init();
}
private function init():void {
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, 465, 465);
graphics.endFill();
twist = new DotTwist(30, 20, 10);
addChild(twist);
twist.x = 232;
twist.y = 232;
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BlurFilter;
class DotTwist extends Sprite {
private var circles:uint;
private var dots:uint;
private var interval:uint;
public function DotTwist(c:uint, d:uint, i:uint) {
circles = c;
dots = d;
interval = i;
init();
}
private function init():void {
for(var n:uint = 0; n < circles; n++) {
var circle:DotCircle = new DotCircle(dots, interval);
addChild(circle);
var pos:Number = interval*n - interval*circles/2;
circle.x = circle.y = pos;
circle.angle = (180/circles)*n;
}
var blur:BlurFilter = new BlurFilter(2, 2, 2);
filters = [blur];
addEventListener(Event.ENTER_FRAME, motion, false, 0, true);
}
public function motion(evt:Event):void {
rotation += 2;
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.ColorTransform;
import flash.filters.GlowFilter;
import frocessing.color.ColorHSV;
class DotCircle extends Sprite {
private var dots:uint;
private var interval:uint;
public var angle:Number;
public var color:ColorHSV;
public function DotCircle(d:uint, i:uint) {
dots = d;
interval = i;
init();
}
private function init():void {
for(var n:uint = 0; n < dots; n++) {
var dot:Dot = new Dot();
addChild(dot);
var pos:Number = interval*n - interval*dots/2;
dot.x = pos;
}
var radian:Number = Math.sin(angle*Math.PI/180);
scaleX = radian;
color = new ColorHSV(60);
var grade:Number = angle/6;
setGlow(grade);
addEventListener(Event.ENTER_FRAME, motion, false, 0, true);
}
public function motion(evt:Event):void {
var radian:Number = Math.sin(angle*Math.PI/180);
scaleX = radian;
alpha = Math.abs(radian)*0.6 + 0.4;
var grade:Number = (angle%360)/6;
setGlow(grade);
angle += 6;
}
private function setGlow(grade:Number):void {
color.h = (325 - 60)/60*grade + 60;
var glow:GlowFilter = new GlowFilter(color.value, 1, 16, 16, 2, 2, false, false);
filters = [glow];
}
}
import flash.display.Shape;
class Dot extends Shape {
private static var radius:Number = 3;
private static var light:Number = 10;
private static var color:uint = 0xFFFFFF;
public function Dot() {
draw();
}
private function draw():void {
graphics.beginFill(color);
graphics.drawCircle(0, 0, radius);
graphics.endFill();
}
}