<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    pageTitle=" ://fonts.xero.style/ PV3D / draw.logo "
    backgroundColor="#000000" backgroundAlpha="1"
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:xx="com.fontvirus.*"
    applicationComplete="init3D()" 
    viewSourceURL="srcview/index.html"
    layout="absolute">
    <mx:states>
        <mx:State name="customColor">
            <mx:AddChild position="lastChild">
                <mx:Panel x="303" width="84" height="429" layout="absolute" id="colorPanel" bottom="28">
                    <mx:Button x="3" y="24" label=" " width="55" fillAlphas="[1.0, 1.0]" fillColors="[#1EFF00, #1EFF00]" id="btnLime" click="setColor(0x00ff00)"/>
                    <mx:Button x="3" y="50" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FF0000, #FF0000]" id="btnRed" click="setColor(0xff0000)"/>
                    <mx:Button x="3" y="77" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#0000FF, #0000FF]" id="btnBlue" click="setColor(0x0000ff)"/>
                    <mx:Button x="3" y="104" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FF00CC, #FF00FF]" id="btnPink" click="setColor(0xff00ff)"/>
                    <mx:Button x="3" y="132" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FFF000, #FFF000]" id="btnYellow" click="setColor(0xfff000)"/>
                    <mx:Button x="3" y="159" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#006600, #006600]" id="btnGreen" click="setColor(0x006600)"/>
                    <mx:Button x="3" y="186" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FFFFFF, #FFFFFF]" id="btnWhile" click="setColor(0xffffff)"/>
                    <mx:Button x="3" y="227" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FF00FF, #00FF00]" id="btnMix1" click="setColor(0xff00ff, 0x00ff00)"/>
                    <mx:Button x="3" y="254" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#00FFFF, #FFF000]" id="btnMix2" click="setColor(0x00ffff, 0xfff00)"/>
                    <mx:Button x="3" y="333" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FF0000, #FFF000]" id="btnMix5" click="setColor(0xffff00, 0xfff00)"/>
                    <mx:Button x="3" y="306" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#0000FF, #00FF00]" id="btnMix4" click="setColor(0x0000ff, 0x00ff00)"/>
                    <mx:Button x="3" y="280" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#00FF00, #FF0000]" id="btnMix3" click="setColor(0x00ff00, 0xff0000)"/>
                    <mx:Button x="3" y="362" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FF0000, #000000]" id="btnMix6" click="setColor(0xff0000, 0x000000)"/>
                    <mx:Button x="3" y="389" width="55" fillAlphas="[1.0, 1.0]" fillColors="[#FFFFFF, #FFF000]" id="btnMix7" click="setColor(0xffffff, 0xfff00)"/>
                    <mx:Label x="11" y="209" text="mixed" color="#FFFFFF"/>
                    <mx:Label x="14" y="5" text="solid" color="#FFFFFF"/>
                </mx:Panel>
            </mx:AddChild>
            <mx:SetProperty target="{btnColor}" name="label" value="v"/>
            <mx:SetProperty target="{btnColor}" name="width" value="34"/>
            <mx:SetEventHandler target="{btnColor}" name="click" handler="switchMenu(&quot;close&quot;)"/>
            <mx:SetStyle target="{btnColor}" name="textRollOverColor" value="#ffffff"/>
            <mx:SetStyle target="{btnColor}" name="textSelectedColor" value="#ffffff"/>
            <mx:RemoveChild target="{btnColor}"/>
            <mx:AddChild position="lastChild" target="{btnColor}"/>
            <mx:SetStyle target="{btnColor}" name="right" value="27"/>
            <mx:SetStyle target="{btnColor}" name="bottom" value="4"/>
            <mx:RemoveChild target="{label1}"/>
            <mx:AddChild position="lastChild" target="{label1}"/>
            <mx:SetProperty target="{label1}" name="text" value="color"/>
            <mx:SetStyle target="{label1}" name="bottom" value="6"/>
            <mx:SetStyle target="{label1}" name="right" value="71"/>
        </mx:State>
    </mx:states>
<mx:Script>
<![CDATA[/*00XXXX                        XXXX00        
           00XXxx                        xxXX00        
           ee0000eeeeRR            RReeee0000ee        
                 xxXX00            00XXxx              
                 XXXX00            00XXXX              
           eexxXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxee        
           00XXXXeeee00XXXXXXXXXXXX00eeeeXXXX00        
       xxXXXXXXXX    00XXXXXXXXXXXX00    XXXXXXXXxx    
       XXXXXXXXXX    00XXXXXXXXXXXX00    XXXXXXXXXX    
   eeeeXXXXXXXXXXeeeeRRXXXXXXXXXXXXRReeeeXXXXXXXXXXeeee
   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
   XXXX""""RRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXRR""""XXXX
   XXXX    00XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX00    XXXX
   XXXX    00XXXX""""""""""""""""""""""""XXXX00    XXXX
   XXRR    00XXXX                        XXXX00    RRXX
   eeXX    00xxxxRR000000ee    ee000000RRxxxx00    XXee
                 xxXXXXXXxx    xxXXXXXXxx                            
                 XXXXXXXXXX    XXXXXXXXXX                       
    _____             __        .__
  _/ ____\___   _____/  |____  _|__|______  __ __ ______
  \   __/  _ \ /    \   __\  \/ /  \_  __ \|  |  |  ___/
   |  |(  <_> )   |  \  |  \   /|  ||  | \/|  |  |___ \
   |__| \____/|___|  /__|   \_/ |__||__|  /\____/____  >
                   \/                     \/         \/
              .  .  d r a w . l o g o  .  . 
                                                        */
//_______________________________________________________
//                                                importz
    import flash.display.*;
    import flash.utils.*;
    //filmed in papervision3D
    import org.papervision3d.core.geom.renderables.*;
    import org.papervision3d.materials.special.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.core.geom.*;
    //custom shit
    import com.fontvirus.*; 
//_______________________________________________________
//                                                   varz            
    private var fps            :FlexFPS;
    private var linez        :Lines3D;
    private var logo        :FullPV3Dlogo;
    private var theholdup    :Timer;
    private var count        :Number = 0;
    private var theColor1    :uint = 0x00ff00;
    private var theColor2    :uint = 0x00000f;
    private var theMix        :Number = 0;
    private var dir            :Boolean = false;
//_______________________________________________________
//                                            constructor    
    private function init3D():void {
        fps = new FlexFPS(0x333333, 0x000000, 0xFFFFFF, 0, "kb");
        addChild(fps);
        
        paperCanvas.view.camera.zoom = 10;

        logo = new FullPV3Dlogo(new ColorMaterial(0x00FF00, 1));
        logo.visible = false;
        paperCanvas.view.scene.addChild(logo);
        
        linez = new Lines3D(new LineMaterial(theColor1));
        linez.moveDown(200);
        paperCanvas.view.scene.addChild(linez);                

        theholdup = new Timer(2, 0);
        theholdup.addEventListener(TimerEvent.TIMER, drawLinez);
        theholdup.start();
        
        addEventListener(Event.ENTER_FRAME, loop3D);
    }
//_______________________________________________________
//                                            render loop
    private function loop3D(e:Event):void {
        fps.update("lines.rendered: " + linez.lines.length); 

        linez.rotationY+=.5;
                
        paperCanvas.view.renderer.renderScene(paperCanvas.view.scene, paperCanvas.view.camera, paperCanvas.view.viewport);
    }
//_______________________________________________________
//                                        create 3D linez
    private function setupLinez():void {
        count = linez.rotationY;
        paperCanvas.view.scene.removeChild(linez);

        linez = new Lines3D(new LineMaterial(theColor1));
        linez.moveDown(200);
        paperCanvas.view.scene.addChild(linez);                

        linez.rotationY = count;
        count = 0;    
    }    
//_______________________________________________________
//                                             trace logo
    private function drawLinez(e:TimerEvent):void {
        if(theColor2 == 0x00000f){
            if(count<logo.geometry.vertices.length-1){
                linez.addNewLine(3, logo.geometry.vertices[count].x, logo.geometry.vertices[count].y, logo.geometry.vertices[count].z, logo.geometry.vertices[count+1].x, logo.geometry.vertices[count+1].y, logo.geometry.vertices[count+1].z);
                count++;
            } else {
                if(count>700) {
                    setupLinez();
                } else {
                    count++;
                }
            }    
        } else {        
            if(count<logo.geometry.vertices.length-1){
                if(!dir){
                     if(theMix<250){
                          theMix+=2;
                      } else {
                          dir=true;
                      }
                } else {
                      if(theMix>1){
                           theMix-=2;
                      } else {
                           dir=false;
                    }
                }
                linez.addLine(new Line3D(linez, new LineMaterial(theColor1*theMix), 3, new Vertex3D(logo.geometry.vertices[count].x, logo.geometry.vertices[count].y, logo.geometry.vertices[count].z), new Vertex3D(logo.geometry.vertices[count+1].x, logo.geometry.vertices[count+1].y, logo.geometry.vertices[count+1].z)));
                count++;
            } else {
                if(count>700) {
                    setupLinez();
                } else {
                    count++;
                }
            }            
        }
    }
//_______________________________________________________
//                                    custom color picker
    private function switchMenu(dir:String):void {
        if(dir == "open"){
            currentState = "customColor";
            colorPanel.x = btnColor.x - 40;
        } else {
            currentState = "";
        }
    }
//_______________________________________________________
//                                      change line color
    private function setColor(color1:uint, color2:uint = 0x00000f):void {
        theColor1 = color1;
        theColor2 = color2;
        setupLinez();
        currentState = "";
    }
//_______________________________________________________
//                                            setup timer
    private function changeSpeed():void {
        theholdup.stop();
        theholdup = new Timer(theSpeed.value, 0);
        theholdup.addEventListener(TimerEvent.TIMER, drawLinez);
        theholdup.start();
    }
]]>
</mx:Script>
<mx:Style>
Panel {
   borderStyle: solid;
   borderColor: #c3c3c3;
   borderThickness: 1;
   headerHeight: 3;
   backgroundAlpha: 0.59;
   backgroundColor: #303030;
   dropShadowEnabled: false;
}
</mx:Style>
<xx:CanvasView3D id="paperCanvas" top="0" bottom="0" left="0" right="0" />
    <mx:ApplicationControlBar right="0" left="0" bottom="0">
        <mx:Label text="speed" color="#FCFCFC"/>
        <mx:HSlider id="theSpeed" value="2" minimum="0.00005" maximum="50" liveDragging="true" change="changeSpeed()"/>
    </mx:ApplicationControlBar>
    <mx:Label text="color" color="#FFFFFF" id="label1" right="71" bottom="6"/>
    <mx:Button label="^" width="35" color="#FFFFFF" fillAlphas="[1.0, 1.0]" fillColors="[#000000, #8B8B8B, #464646, #000000]" id="btnColor" click="switchMenu(&quot;open&quot;)" right="27" bottom="4" themeColor="#8B8B8B" textRollOverColor="#ffffff" textSelectedColor="#ffffff"/>
</mx:Application>