レゴタウンみたいなかわいいオブジェが作れるクラス
レゴタウンみたいなかわいいオブジェが作れるクラスがあったのでちょっと使ってみました。
こんな感じ
http://moeten.info/flex/20081014_as3isolibTest/bin-release/main.html
as3isolibっといライブラリを使用します。
as3isolib
ソースコードはこちら
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" backgroundColor="0x333333" viewSourceURL="srcview/index.html"> <mx:Script> <![CDATA[ import as3isolib.display.primitive.IsoBox; import as3isolib.display.scene.IsoScene; import as3isolib.display.scene.IsoGrid; import as3isolib.display.IsoSprite; import as3isolib.enum.RenderStyleType; import flash.display.Sprite; private function init():void{ setScene(); setText(); setBox(); } //シーンの作成 private var scene:IsoScene; private function setScene():void{ scene = new IsoScene(); scene.hostContainer = myUI; } //文字を描写 private var bd:BitmapData; private function setText():void{ bd = new BitmapData( myTxt.width , myTxt.height ); bd.draw( myTxt ); } //箱を作成 private function setBox():void{ scene.removeAllChildren(); var w:int = bd.width; var h:int = bd.height; var size:int = 20; for( var i:int = 1 ; i < w ; i++ ){ for( var j:int = 1 ; j < h ; j++ ){ if( bd.getPixel( i , j ) != 0xffffff ){ var box:IsoBox = new IsoBox(); // box.styleType = RenderStyleType.SHADED // box.faceColors = [0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff] // box.faceAlphas = [.5, .5, .5, .5, .5, .5]; box.setSize( size,size,size); box.moveTo( i * size , j * size , 0 ); scene.addChild( box ); } } } var grid:IsoGrid = new IsoGrid(); grid.showOrigin = true; // grid.styleType = RenderStyleType.SHADED; // grid.faceColors = [0xff0000, 0x00ff00, 0x0000ff, 0xff0000, 0x00ff00, 0x0000ff] grid.cellSize = size; grid.setGridSize(200,200,200); scene.addChild(grid); scene.render(); } //文字再描画 private function onChange():void{ setText(); setBox(); } ]]> </mx:Script> <mx:UIComponent id="myUI" width="500" height="500" verticalCenter="0" horizontalCenter="0" /> <mx:Canvas x="10" y="10" width="248" height="47" backgroundColor="0xffffff" backgroundAlpha="0.8" cornerRadius="10" borderColor="0xcccccc" borderStyle="solid" borderThickness="3"> <mx:TextInput id="myTxt" x="10" y="10" text="ハルヒ" borderThickness="0" borderColor="0xffffff" borderStyle="solid" enter="onChange()"/> <mx:Button x="178" y="10" label="描画" click="onChange()"/> </mx:Canvas> </mx:Application>