LoginSignup
0
0

More than 5 years have passed since last update.

鏡面反射

Posted at

ActionScript 3.0による鏡面反射の実装です。

スライド.jpg

sample.as
var urlReq:URLRequest = new URLRequest("AutumnLeaves.jpg");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
loader.load(urlReq);
function completeHandler(e:Event):void {
        var gmask:Sprite = new Sprite();
        var bmpSprite:Sprite= new Sprite();
        var _bmpSprite:Sprite= new Sprite();
        var _bmp:Bitmap = Bitmap(loader.content);
        _bmp.scaleY=-1.0;
        _bmp.y=_bmp.height*2;
        var fillType:String = GradientType.LINEAR;
        var colors:Array = [0x000000, 0x000000];
        var alphas:Array = [0.4, 1];
        var ratios:Array = [0, 255];
        var matrix:Matrix = new Matrix();
        matrix.createGradientBox(_bmp.height,_bmp.width,Math.PI/2,_bmp.width);
        gmask.graphics.beginGradientFill(fillType, colors, alphas, ratios, matrix);
        gmask.graphics.drawRect(0,0,_bmp.width,_bmp.height);
        gmask.y = _bmp.height;
        _bmpSprite.addChild(_bmp);
        _bmpSprite.addChild(gmask);
        addChild(_bmpSprite);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0