In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

BitmapDataをDrawTrianglesでタイル状に貼る

UVTは0~1.0っていう決まりじゃなかったんだ。。
Get Adobe Flash player
by Kay 27 Feb 2011
    Embed
/**
 * Copyright Kay ( http://wonderfl.net/user/Kay )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5KF3
 */

package {
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.system.LoaderContext;
    import flash.events.Event;
    public class TestUVT extends Sprite {
        public var bmd:BitmapData;
        public var loader:Loader = new Loader();
        public function TestUVT():void {
            var url:String = "http://assets.wonderfl.net/images/related_images/1/15/151d/151d5751ce2b8ed4033d8128996a6ba4d8388fcam";
            var urlReq:URLRequest = new URLRequest(url);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE , complete);
            loader.load(new URLRequest(url), new LoaderContext(true));
        }
        public function complete(e:Event):void {
            bmd = new BitmapData(100,100);
            bmd.draw(loader);
            
            // drawRectでタイル状に塗る
            graphics.beginBitmapFill(bmd);
            graphics.drawRect(0,0,200,200);
            graphics.endFill();
            
            // drawTriangleでタイル状に塗る(UVT無し)
            var verts:Vector.<Number> = new Vector.<Number>();
            var indices:Vector.<int> = new Vector.<int>();
            verts.push(200,0, 400,0, 200,200, 400,200);
            indices.push(0,1,2);
            graphics.beginBitmapFill(bmd);
            graphics.drawTriangles(verts,indices,null);
            graphics.endFill();
            
            // drawTrianglesでタイル状に塗る(UVT有り)
            var uvts:Vector.<Number> = new Vector.<Number>();
            indices = new Vector.<int>();
            indices.push(3,2,1);
            uvts.push(0,0, 4,0, 0,4, 4,4);    //4!!
            graphics.beginBitmapFill(bmd);
            graphics.drawTriangles(verts,indices,uvts);
            graphics.endFill();
        }
    }
}