您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關使用Flash怎么實現一個光帶效果,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。
部分代碼:
/** * Copyright david1 ( http://wonderfl.net/user/david1 ) * MIT License ( http://www.opensource.org/licenses/mit-license.php ) * Downloaded from: http://wonderfl.net/c/gjQv */ // forked from one_truth's forked from: 光るリボン(Ribbon Light) // forked from mousepancyo's 光るリボン(Ribbon Light) // forked from nutsu's SketchSample6 package { import flash.display.Sprite; import flash.display.BitmapData; import flash.display.Bitmap; import flash.events.Event; import flash.filters.BlurFilter; import flash.geom.Point; import flash.geom.ColorTransform; [SWF(width=465,height=465,backgroundColor=0x000000,frameRate=60)] public class Main extends Sprite{ private const WIDTH:Number = 465; private const HEIGHT:Number = 465; private var _sketch:CurveSketch; private var _bmd:BitmapData; private var _bm:Bitmap; private var _container:Sprite = new Sprite(); public function Main() { graphics.beginFill(0) graphics.drawRect(0, 0, WIDTH, HEIGHT) graphics.endFill() addChild(_container); // _sketch = new CurveSketch(); _bmd = new BitmapData(WIDTH, HEIGHT, true, 0); _container.addChild(_sketch); _container.addChild(_bm = new Bitmap(_bmd) as Bitmap); _bm.blendMode = "add"; // addEventListener(Event.ENTER_FRAME, update); } private function update(e:Event):void{ _bmd.draw(_sketch, null, null, "add"); _bmd.applyFilter(_bmd, _bmd.rect, new Point(), new BlurFilter(8, 8, 4)); } } } //package { import frocessing.display.F5MovieClip2D; import frocessing.geom.FGradientMatrix; import frocessing.color.ColorHSV class CurveSketch extends F5MovieClip2D { //加速度運動の変數 //位置 private var xx:Number; private var yy:Number; //速度 private var vx:Number; private var vy:Number; //加速度の係數 private var ac:Number; //速度の減衰係數 private var de:Number; //描畫座標 private var px0:Array; private var py0:Array; private var px1:Array; private var py1:Array; private var t:Number = 0 //描畫グループ private var shapes:Array; public function CurveSketch() { //初期化 vx = vy = 0.0; xx = mouseX; yy = mouseY; ac = 0.06; de = 0.9; px0 = [xx, xx, xx, xx]; py0 = [yy, yy, yy, yy]; px1 = [xx, xx, xx, xx]; py1 = [yy, yy, yy, yy]; shapes = []; //線と塗りの色指定 noStroke(); } public function draw():void { //加速度運動 xx += vx += ( mouseX - xx ) * ac; yy += vy += ( mouseY - yy ) * ac; var len:Number = mag( vx, vy ); //新しい描畫座標 var x0:Number = xx + 1 + len * 0.1; var y0:Number = yy - 1 - len * 0.1; var x1:Number = xx - 1 - len * 0.1; var y1:Number = yy + 1 + len * 0.1; //描畫座標 px0.shift(); px0.push( x0 ); py0.shift(); py0.push( y0 ); px1.shift(); px1.push( x1 ); py1.shift(); py1.push( y1 ); var _px0:Array = [px0[0], px0[1], px0[2], px0[3]]; var _py0:Array = [py0[0], py0[1], py0[2], py0[3]]; var _px1:Array = [px1[0], px1[1], px1[2], px1[3]]; var _py1:Array = [py1[0], py1[1], py1[2], py1[3]]; shapes.push( { px0:_px0, py0:_py0, px1:_px1, py1:_py1, mtx:null} ); if (shapes.length >= 50) shapes.shift(); var shapesshapesLength:int = shapes.length; for (var i:int = shapesLength-1; i >= 0; i--) { var sh:Object = shapes[i]; var color:ColorHSV = new ColorHSV(t, 0.8, 1, 0.1) t += 0.05; beginFill(int(color), 0.2) beginShape(); curveVertex( sh.px0[0], sh.py0[0] ); curveVertex( sh.px0[1], sh.py0[1] ); curveVertex( sh.px0[2], sh.py0[2] ); curveVertex( sh.px0[3], sh.py0[3] ); vertex( sh.px1[2], sh.py1[2] ); curveVertex( sh.px1[3], sh.py1[3] ); curveVertex( sh.px1[2], sh.py1[2] ); curveVertex( sh.px1[1], sh.py1[1] ); curveVertex( sh.px1[0], sh.py1[0] ); endShape(); } //減衰処理 vx *= de; vy *= de; } } //}
關于使用Flash怎么實現一個光帶效果就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。