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*****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
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