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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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*****VARIABLER*****VARIABLER*****VARIABLER*****
        
        var background, backgroundColor;
        var circles = [];
        var iCircles = 0;
        var colorList = [0xff7733, 0xff4d4d, 0xffb366, 0xffd480]; // List of colors for the circles
        var beatLock = false;
        var midBackground, midBackgroundColor;
        var circleContainer;
        //mus
        var imageSprite;
        var mousedown = false;

  

// BACK*****BACK*****BACK*****BACK*****BACK*****BACK*****BACK*****BACK*****BACK*****
        SPF.set({

            at:"back",

            init: function(PIXI, input) {
                
                //baggrund
                backgroundColor = input.colors[15];
                background = new PIXI.Graphics();
                input.container.addChild(background);
              
                circleContainer = new PIXI.Container();
                input.container.addChild(circleContainer);

            },

            resize :function(PIXI, input) {

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

               
            },
          
            render: function(PIXI, input) {
              
              
              // BACKGROUND CHANGING COLOR
              
              if(input.cast != null){

                    if(input.cast.id == "singer"){
                        backgroundColor = input.colors[16];

                    } else if(input.cast.id == "bass"){

                        backgroundColor = input.colors[16];

                    } else if(input.cast.id == "drums"){

                        backgroundColor = input.colors[16];

                    } else if(input.cast.id == "all"){

                        backgroundColor = input.colors[15];

                    }

                }
              background.clear();
              background.beginFill(backgroundColor, 1);
              background.drawRect(0,0,input.width,input.height);
              background.endFill();
              
              
              
              // CIRCLES THAT GROW
              
              //Beatlock = 
              if (beatLock == false && input.beat != null && input.beat.id == "on") {
                var circle = new PIXI.Graphics();
                //var color = input.colors[Math.floor(Math.random() * input.colors.length)];
                 //var color = colorList[Math.floor(Math.random() * colorList.length)];
                var color = colorList[iCircles];
                iCircles = iCircles + 1;
                if (iCircles >= colorList.length) {
                  iCircles = 0;
                }
                circle.beginFill(color);
                circle.drawCircle(0,0,50);
                circle.endFill();
              //Circles emerges from center -v
                circle.position.set(input.width/2, input.height/2);
              //Cirles creates on mouse position
                //circle.position.set(input.mouseTouchPosition.x, input.mouseTouchPosition.y);
                circleContainer.addChild(circle);
                //lav et array "circles" med cirkler
                circles.push(circle);
                beatLock = true;
                setTimeout(function() {
                  beatLock = false;
                }, 100);
              }
              
              for (var i = 0; i < circles.length; i++) {
                var myCircle = circles[i];
                var newScale = myCircle.scale.x + 0.15;
                myCircle.scale.x = newScale;
                myCircle.scale.y = newScale;
                //myCircle.alpha = myCircle.alpha - 0.01; // We take a bit of transparency every frame
              }
              
              var firstCircle = circles[0];
              if (firstCircle != null && firstCircle.width > input.width + 2000) {
                circleContainer.removeChild(firstCircle);
                circles.shift();
              }
              
            }
          
        });

// MID*****MID*****MID*****MID*****MID*****MID*****MID*****MID*****MID*****MID*****MID*****
        SPF.set({

            at:"mid",
          
            init: function(PIXI, input) {
              
                midBackground = new PIXI.Graphics();
                input.container.addChild(midBackground);
                midBackground.clear();
                midBackground.beginFill(0x4d0026);
                midBackground.alpha = 1;
                midBackground.drawRect(0,0,input.width,input.height);
                midBackground.endFill();
                
                SPF.midgroundMask(true);
              
            },
          
        render: function(PIXI, input) {
     
     if(input.cast != null){

                    if(input.cast.id == "singer"){
                        midBackground.clear();
                        midBackground.beginFill(0x4d0026);
                        midBackground.alpha = 0.3;
                        midBackground.drawRect(0,0,input.width,input.height);
                        midBackground.endFill();

                    } else if(input.cast.id == "bass"){

                        midBackground.clear();
                        midBackground.beginFill(0x4d0026);
                        midBackground.alpha = 0.3;
                        midBackground.drawRect(0,0,input.width,input.height);
                        midBackground.endFill();

                    } else if(input.cast.id == "drums"){

                        //midBackground = input.colors[16];
                        midBackground.clear();
                        midBackground.beginFill(0x4d0026);
                        midBackground.alpha = 0.3;
                        midBackground.drawRect(0,0,input.width,input.height);
                        midBackground.endFill();

                    } else if(input.cast.id == "all"){

                        midBackground.clear();
                        midBackground.beginFill(0x4d0026);
                        midBackground.alpha = 1;
                        midBackground.drawRect(0,0,input.width,input.height);
                        midBackground.endFill();

                    }

                }
          
          /*
              midBackground.clear();
              midBackground.beginFill(midBackgroundColor, 1);
              midBackground.drawRect(0,0,input.width,input.height);
              midBackground.endFill();
              */
     
     
   }    
          
});

//******FORE******FORE******FORE******FORE******FORE******FORE******FORE******FORE******FORE
var foreSprite;

SPF.set({

  at: 'fore', // You can use 'back', 'mid' and 'fore'

  load: function(PIXI, input) {
    // Use this to preload assets (optional)
    return [input.patterns.botanicorganic2];
  },

  init: function(PIXI, input) {
    
    
    
    //sprite fr framework
    //foreSprite = new PIXI.extras.TilingSprite(input.patterns.botanicorganic2, 1, 1);
    
    //texture fra nettet
    var texture = PIXI.Texture.fromImage('https://lh6.googleusercontent.com/13TvXOk8aMAsOXVelNtN2qSSZ6OwpU9pTrziViZJ-EjHg5vRHJkor_fUhAU_BljYreblq8FQUgMOdi8=w1322-h930');
    foreSprite = new PIXI.extras.TilingSprite(texture);
    
    foreSprite.anchor.set(0);
    input.container.addChild(foreSprite);
    
    //mus
    var texture1 = PIXI.Texture.fromImage('https://lh5.googleusercontent.com/KdAHXbtqUI6dWiNgtXuWgQzs1mfdBSNUFmwP8un4LXGb0icTqf0bom5SMXLIx6QrBpZ5Na_8_BjOeNs=w1322-h991');

   imageSprite = new PIXI.Sprite(texture1);
    imageSprite.alpha = 0;
    //ANCHOR POINT I MIDTEN
    imageSprite.anchor.set(0.5,0.5);

    input.container.addChild(imageSprite);
    
    
  },

  
  
  render: function(PIXI, input) {
    //  This is called on every frame, put your animation here
    foreSprite.alpha = input.audio.frequencies()[500] / 200;
    
    //*******MOUSE*******MOUSE*******MOUSE*******MOUSE*******MOUSE*******MOUSE
    if (mousedown){
      imageSprite.rotation += 0.1;
       var xy = input.mouseTouchPosition;
        imageSprite.position.set(xy.x,xy.y);
    }
    
  }, //komma og mouse function
  
  mouseDownTouchStart: function(PIXI, input) {
    
        mousedown = true;
    //billedets alpha værdi
        imageSprite.alpha = 0.6;
    },
  
  mouseUpTouchEnd: function(PIXI, input) {
       TweenLite.to(imageSprite, 0.2, {
         alpha: 0,
         onComplete: function() {
           mousedown = false;
         }
       })
    
    
  },

  resize: function(PIXI, input) {
    //  This is called on every frame, put your animation here
    foreSprite.width = input.width;
    foreSprite.height = input.height;
  }
 
 
    
});




SPF.start();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console