cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              body{
  margin:0;
  padding: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

            
          
!
            
                     

      //variabler//
       var background;
       var firkant;
       var masker;
       var trekant;
     
      
      //musen//
        var maxCount = 200;
        var count = 1;
        var sprites, sprite;
        var midBackground;
        var allGraphics;
      


            //musen//
            function addGraphic(PIXI, input){

            sprite = new PIXI.Sprite(allGraphics[Math.round(Math.random()*(              allGraphics.length-1))] );

            sprite.anchor.set(0.5);
            sprite.scale.set(0.2);

            sprite.rotation = (Math.random()*90)*4;

            sprite.x = input.width/2;
            sprite.y = input.height/2;

            if( input.mouseTouchPosition.x != 0 &&  input.mouseTouchPosition.y != 0){
                sprite.x = input.mouseTouchPosition.x;
                sprite.y = input.mouseTouchPosition.y;
            }

            if(input.container.children[count])
                input.container.removeChildAt(count);

            input.container.addChildAt(sprite, count);

            if(count >= maxCount) {
                count = 1
            } else {
                count++;
            };

        };


       //baggrunden-------------------------------------//

       SPF.set({
     
            at:"back",

            init: function(PIXI, input) {

                background = new PIXI.Graphics();
                input.container.addChild(background);
              
                firkant = new PIXI.Graphics();
                input.container.addChild(firkant);
              
        

            },

            resize :function(PIXI, input) {

                var w =  input.width;
                var h =  input.height;
              
                var w2 =  input.width;
                var h2 =  input.height;
              
               

                background.clear();
                background.beginFill(input.colors[8], 1);
                background.drawRect(0,0,w,h);
                background.endFill();
              
                firkant.clear();
                firkant.beginFill(input.colors[9], 1);
                firkant.drawRect(0,0,w2/1,h2/2);
                firkant.endFill();
              
                
              
             
            }
         
          

        });
    //slutbag//


    //MIDgrunden----------------------------------------------------//   

        SPF.set({

            at:"mid",
          
                load: function(PIXI, input) {

                return [input.patterns.handdrawnanimal,input.maskers.handdrawnanimal1];

            },
          

            init: function(PIXI, input) {
              
                 mid = new PIXI.Graphics();
                input.container.addChild(mid);
                graphics = new PIXI.Graphics();
                graphics.beginFill(0xABC5C6);
                graphics.drawRect(0, 0, input.width, input.height);

                input.container.addChild(graphics);

                // We make the video be a mask to the midground layer
                SPF.midgroundMask(true);
              

                midBackground = new PIXI.extras.TilingSprite(input.patterns.handdrawnanimal, 1, 1);
                midBackground.anchor.set(0);
                input.container.addChild(midBackground);

                masker = SPF.fullscreenSprite(input.container, input.patterns.handdrawnanimal);
                input.container.addChild(masker);

                midBackground.mask = masker;
            },
          
          

            mouseDownTouchStart: function(PIXI, input) {
                midBackground.mask = null;
            },
          
          

            mouseUpTouchEnd: function(PIXI, input) {
                midBackground.mask = masker;

            },
          
          


            resize: function(PIXI, input) {

                var w =  input.width;
                var h =  input.height;

                mid.clear();
                mid.beginFill(input.colors[2], 1);
                mid.drawRect(0,0,w/1,h/1);
                mid.endFill();

                mid.position.set(w/4, h/4);

                midBackground.width = w;
                midBackground.height = h;

            },
          
         
            

          
          
          
          
          
        });

        //slutmid//


         //Forgrunden-----------------------------//
        //denlillastreg//


          var front1;
          var front2;
          var front3;
          var front4;
        

          SPF.set({

            at:"fore",
            

          init: function(PIXI, input) {
              
                allGraphics = [ input.graphics.handdrawnanimal1, input.graphics.handdrawnanimal2,input.graphics.handdrawnanimal3];
            
                var c = new PIXI.Container();
                input.container.addChild(c);

                front1 = new PIXI.Graphics();
                c.addChild(front1);
                front2 = new PIXI.Graphics();
                c.addChild(front2);
                front3 = new PIXI.Graphics();
                c.addChild(front3);
                front4 = new PIXI.Graphics();
                c.addChild(front4);

            },

            resize :function(PIXI, input) {

                var w =  input.width;
                var h =  input.height;

                front1.clear();
                front1.beginFill(input.colors[14]);
                front1.drawRect(0, h * 0.2 - 50, w, 100);
                front1.endFill();

                front2.clear();
                front2.beginFill(input.colors[13]);
                front2.drawRect(0, h * 0.4 - 50, w, 100);
                front2.endFill();

                front3.clear();
                front3.beginFill(input.colors[12]);
                front3.drawRect(0, h * 0.6 - 50, w, 100);
                front3.endFill();

                front4.clear();
                front4.beginFill(input.colors[14]);
                front4.drawRect(0, h * 0.8 - 50, w, 100);
                front4.endFill();

            },
            
            render: function(PIXI, input) {
              
                addGraphic(PIXI, input);
              
                front1.alpha = 0.5 + Math.sin(2 * input.currentTime) / 2;
                front2.alpha = 0.5 + Math.sin(2 * input.currentTime + 200) / 2;
                front3.alpha = 0.5 + Math.sin(2 * input.currentTime + 400) / 2;
                front4.alpha = 0.5 + Math.sin(2 * input.currentTime + 600) / 2;
              
            }
            

        });





       //slutalt------------------------------------//


        SPF.info({
            debug: false,
            title: "RE Test",
            tip: "",
            firstName: "Ramiro",
            lastName: "Espada",
            email: "re@ramiroespada.com"
        });

        SPF.start();

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console