<commit_before>package sk.yoz.ycanvas.demo.simple
{
    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    
    import sk.yoz.ycanvas.interfaces.IPartition;
    import sk.yoz.ycanvas.stage3D.YCanvasStage3D;
    import sk.yoz.ycanvas.utils.ILayerUtils;
    import sk.yoz.ycanvas.utils.IPartitionUtils;
    import sk.yoz.ycanvas.utils.TransformationUtils;
    
    [SWF(frameRate="60", backgroundColor="#ffff00")]
    public class ApplicationDemo extends Sprite
    {
        private var canvas:YCanvasStage3D;
        private var position:Point;
        
        public function ApplicationDemo()
        {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            
            canvas = new YCanvasStage3D(stage, stage.stage3Ds[0], viewPort, canvasInit);
            canvas.partitionFactory = new PartitionFactory;
            canvas.layerFactory = new LayerFactory(canvas.partitionFactory);
            
            stage.addEventListener(MouseEvent.CLICK, function(event:Event):void
            {
                var bitmap:Bitmap = new Bitmap(canvas.bitmapData);
                bitmap.width = 300;
                bitmap.height = 300;
                stage.addChild(bitmap);
            });
        }
        
        private function get viewPort():Rectangle
        {
            return new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
        }
        
        private function canvasInit():void
        {
            canvas.center = new Point(35e6, 25e6);
            canvas.scale = 1 / 16384;
            render();
            
            stage.addEventListener(Event.RESIZE, onStageResize);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
        }
        
        private function render():void
        {
            canvas.render();
            IPartitionUtils.disposeInvisible(canvas);
            ILayerUtils.disposeEmpty(canvas);
            
            var main:Layer = canvas.layers[canvas.layers.length - 1] as Layer;
            for each(var layer:Layer in canvas.layers)
                (layer == main) ? startLoading(layer) : stopLoading(layer);
        }
        
        private function startLoading(layer:Layer):void
        {
            var partition:Partition;
            var list:Vector.<IPartition> = layer.partitions;
            for(var i:uint = 0, length:uint = list.length; i < length; i++)
            {
                partition = list[i] as Partition;
                if(!partition.loading && !partition.loaded)
                    partition.load();
            }
        }
        
        private function stopLoading(layer:Layer):void
        {
            var partition:Partition;
            var list:Vector.<IPartition> = layer.partitions;
            for(var i:uint = 0, length:uint = list.length; i < length; i++)
            {
                partition = list[i] as Partition;
                if(partition.loading)
                    partition.stopLoading();
            }
        }
        
        private function onStageResize(event:Event):void
        {
            canvas.viewPort = viewPort;
            render();
        }
        
        private function onMouseDown(event:MouseEvent):void
        {
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            position = canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY));
        }
        
        private function onMouseMove(event:MouseEvent):void
        {
            var current:Point = canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY));
            var center:Point = new Point(
                canvas.center.x - current.x + position.x, 
                canvas.center.y - current.y + position.y);
            TransformationUtils.moveTo(canvas, center);
            position = canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY));
            render();
        }
        
        private function onMouseUp(event:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        }
        
        private function onMouseWheel(event:MouseEvent):void
        {
            TransformationUtils.scaleTo(canvas, 
                canvas.scale * (event.delta > 0 ? 1.5 : 0.7), 
                canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY)));
            render();
        }
    }
}<commit_msg>removed bitmap screenshot from demo<commit_after>package sk.yoz.ycanvas.demo.simple
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    
    import sk.yoz.ycanvas.interfaces.IPartition;
    import sk.yoz.ycanvas.stage3D.YCanvasStage3D;
    import sk.yoz.ycanvas.utils.ILayerUtils;
    import sk.yoz.ycanvas.utils.IPartitionUtils;
    import sk.yoz.ycanvas.utils.TransformationUtils;
    
    [SWF(frameRate="60", backgroundColor="#ffffff")]
    public class ApplicationDemo extends Sprite
    {
        private var canvas:YCanvasStage3D;
        private var position:Point;
        
        public function ApplicationDemo()
        {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            
            canvas = new YCanvasStage3D(stage, stage.stage3Ds[0], viewPort, canvasInit);
            canvas.partitionFactory = new PartitionFactory;
            canvas.layerFactory = new LayerFactory(canvas.partitionFactory);
        }
        
        private function get viewPort():Rectangle
        {
            return new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
        }
        
        private function canvasInit():void
        {
            canvas.center = new Point(35e6, 25e6);
            canvas.scale = 1 / 16384;
            render();
            
            stage.addEventListener(Event.RESIZE, onStageResize);
            stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
        }
        
        private function render():void
        {
            canvas.render();
            IPartitionUtils.disposeInvisible(canvas);
            ILayerUtils.disposeEmpty(canvas);
            
            var main:Layer = canvas.layers[canvas.layers.length - 1] as Layer;
            for each(var layer:Layer in canvas.layers)
                (layer == main) ? startLoading(layer) : stopLoading(layer);
        }
        
        private function startLoading(layer:Layer):void
        {
            var partition:Partition;
            var list:Vector.<IPartition> = layer.partitions;
            for(var i:uint = 0, length:uint = list.length; i < length; i++)
            {
                partition = list[i] as Partition;
                if(!partition.loading && !partition.loaded)
                    partition.load();
            }
        }
        
        private function stopLoading(layer:Layer):void
        {
            var partition:Partition;
            var list:Vector.<IPartition> = layer.partitions;
            for(var i:uint = 0, length:uint = list.length; i < length; i++)
            {
                partition = list[i] as Partition;
                if(partition.loading)
                    partition.stopLoading();
            }
        }
        
        private function onStageResize(event:Event):void
        {
            canvas.viewPort = viewPort;
            render();
        }
        
        private function onMouseDown(event:MouseEvent):void
        {
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
            position = canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY));
        }
        
        private function onMouseMove(event:MouseEvent):void
        {
            var current:Point = canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY));
            var center:Point = new Point(
                canvas.center.x - current.x + position.x, 
                canvas.center.y - current.y + position.y);
            TransformationUtils.moveTo(canvas, center);
            position = canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY));
            render();
        }
        
        private function onMouseUp(event:MouseEvent):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        }
        
        private function onMouseWheel(event:MouseEvent):void
        {
            TransformationUtils.scaleTo(canvas, 
                canvas.scale * (event.delta > 0 ? 1.5 : 0.7), 
                canvas.globalToCanvas(new Point(stage.mouseX, stage.mouseY)));
            render();
        }
    }
}
{'fraction_non_alphanumeric': 0.09402347918890075, 'fraction_numerical': 0.007257203842049093, 'mean_word_length': 1.8622480146609652, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4672407', 'n_tokens_mistral': 2528, 'n_tokens_neox': 2471, 'n_words': 443}