This code(from http://lab.andre-michelle.com/) is used for displaying panoramic pictures;I just rewrited it into as3.0.
code:
package { import flash.display.*; import flash.events.*; import flash.geom.*; public class Panorama2D extends Sprite { var g:Sprite = new Sprite(); var image:BitmapData = new source(0, 0); /*your panoramic picture - suppose to be W*(H=256)(class name "source")in the lib*/ var output:BitmapData = new BitmapData(256, 256, true, 0); var bounds:Rectangle = output.rect; var origin:Point = new Point(); var dx:Number = 0; var dy:Number = 0; var matrix:Matrix = new Matrix(); public function Panorama2D():void { var container:Bitmap = new Bitmap(output); addChild(container); addEventListener(Event.ENTER_FRAME,onEnterFrame); } function onEnterFrame(event:Event):void { dx = dx + (128 - mouseX) / 8; matrix.tx=dx; g.graphics.beginBitmapFill(image, matrix, true); g.graphics.drawRect(0, 0, 256, 256); g.graphics.endFill(); matrix.tx=0; matrix.ty=0; output.fillRect(bounds, 0); output.draw(g, matrix); g.graphics.clear(); } }//end of class }//end of package
Links:
PanoPaint: a 360 degree panorama painting tool designed to aid in creation of immersive concept art for game and film scenes.
No comments:
Post a Comment