Processing風Flash「Frocessing」でフラクタルを描こう! サンプルコード ll_koba_ll forked:1favorite:15lines:62license : MIT License modified : 2009-11-18 22:20:39 Embed Tweet package { import flash.display.Sprite; import flash.events.MouseEvent; import frocessing.display.F5MovieClip2DBmp public class C3_1 extends F5MovieClip2DBmp { //120度 private const ANGLE_1:Number = Math.PI * 2 / 3; //240度 private const ANGLE_2:Number = Math.PI * 4 / 3; //フラクタルの回転角度 private var _theta:Number; //線分の長さ private var _length:Number; //線分の増加量 private var _vl:Number; public function C3_1() { } public function setup():void { _theta = 0; _length = 10; _vl = 1; background( 0 ); } public function draw():void { //fadeout noStroke(); fill(0,0,0,.03); rect(0, 0, width, height); if (!isMousePressed){ //マウスがクリックされていなければ初期値に戻す _length = 10; _vl = 1 }else { //マウス位置から生成する translate(mouseX,mouseY ); //毎フレームごとに線色を変える stroke(random(0xFFFFFF, 0xAAAAAA), 0.5); //フラクタル生成 branch(_length, _theta); //回転 _theta += .1; //長さに加算 _length += _vl; } //線分の増減 if (_length > 110) _vl = -1 else if (_length < 10) _vl = 1; } public function branch( h:Number,theta:Number ):void { h *= 0.66; if (h > 4) { //一本目の枝 pushMatrix(); rotate(theta); line(0,0,0,-h); translate(0,-h); branch(h,theta); popMatrix(); //二本目の枝 pushMatrix(); rotate(theta + ANGLE_1); line(0, 0, 0, -h); translate( 0, -h); branch(h, theta); popMatrix(); //三本目の枝 pushMatrix(); rotate(theta + ANGLE_2); line(0,0,0,-h); translate(0,-h); branch(h,theta); popMatrix(); } } } } Code Fullscreen Preview Fullscreen szisoq Miya gomako siouxcitizen.. tkinjo linktale plankton kenz hidrodixtion.. : awesomefrocessingmouse gen_dot : effectフラクタルcool alwAYs : BetweenAS3 stwind : frocessing soundkitchen.. : F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5F5 Kevin_Yin : coloreffectmouse oreore : フラクタル BetweenAS3 F5 awesome color effect frocessing mouse web+db54 フラクタル height mouseY mouseX width Math.PI Math.random Number sort new page view favorite forked pv408 forked from: Processing風Flash「.. taka_milk forked:0 favorite:2lines:62 (diff:1)