Carpets miyaoka forked:1 favorite:5 lines:89 license : MIT License modified : 2009-09-17 14:24:57 package { import flash.display.*; import flash.events.*; import flash.geom.*; import caurina.transitions.Tweener; import flash.filters.*; [SWF(width = "465", height = "465", backgroundColor = 0xFFFFFF, frameRate = "60")] public class Carpets extends Sprite { public function Carpets() { var sw:Number = stage.stageWidth; var sh:Number = stage.stageHeight; var lastPt:Point = new Point(); var lastAngle:Number = 0; var bmd:BitmapData = new BitmapData(sw, sh, true, 0x00000000); var gf:GlowFilter = new GlowFilter( 0x000000, 0.5, 2, 2, 5, 1, false, false ); addChild(new Bitmap(bmd)); stage.addEventListener(MouseEvent.MOUSE_MOVE, function ():void { var angle:Number = (Math.atan2( -(mouseY - lastPt.y), mouseX - lastPt.x) + Math.PI * 2) % (Math.PI * 2); lastPt = new Point(mouseX, mouseY); lastAngle = angle; var c:Carpet = new Carpet(); c.x = mouseX; c.y = mouseY; c.rotation = 90 - angle * 180 / Math.PI -90; addChild(c); c.addEventListener(Event.COMPLETE, function ():void { var mtx:Matrix = new Matrix(); mtx.rotate(-angle); mtx.translate(c.x, c.y); var tempBmd:BitmapData = new BitmapData(bmd.width, bmd.height, true, 0x00000000); tempBmd.draw(c, mtx); tempBmd.applyFilter(tempBmd, tempBmd.rect, tempBmd.rect.topLeft, gf); bmd.draw(tempBmd); tempBmd.dispose(); c.removeEventListener(Event.COMPLETE, arguments.callee); removeChild(c); c = null; }); }) } } } import flash.display.*; import flash.events.*; import flash.geom.*; import caurina.transitions.Tweener; class Carpet extends Shape { public var f:Number = 0; public function Carpet():void { var radius:Number = 700; var clr:uint = Math.random() * 0xffffff; var openAngle:Number = Math.PI * 0.03 * Math.random() * Math.random(); var ptSt1:Point = Point.polar(radius, Math.PI + openAngle); var ptSt2:Point = Point.polar(radius, Math.PI - openAngle); var ptEnd1:Point = Point.polar(radius, 0 - openAngle * Math.random()); var ptEnd2:Point = Point.polar(radius, 0 + openAngle * Math.random()); var g:Graphics = graphics; g.beginFill(clr); Tweener.addTween(this, { time: 1.0, f:1, transition: "linear", onUpdate: function ():void { g.clear(); g.beginFill(clr); g.moveTo(ptSt1.x, ptSt1.y); g.lineTo(ptSt2.x, ptSt2.y); var pt:Point = Point.interpolate(ptEnd2, ptSt2, f) g.lineTo(pt.x, pt.y); pt = Point.interpolate(ptEnd1, ptSt1, f) g.lineTo(pt.x, pt.y); }, onComplete: function ():void { dispatchEvent(new Event(Event.COMPLETE)); } }); } } Code Fullscreen Preview Fullscreen tkinjo sw_lucchini paq KinkumaDesig.. : 面白いなー halfmile : 特效 矢量地毯变位图 特效 Point.polar Point.polar angle angle Point.interpolate Point.interpolate mouseY mouseY mouseX mouseX Event.COMPLETE Event.COMPLETE Math.PI Math.PI GlowFilter GlowFilter dispatchEvent dispatchEvent lineTo lineTo sort new page view favorite forked pv 484 forked from: Carpets attunedesigns forked:0 favorite:0 lines:89 ( diff:2 )