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;
  cursor: none;
}


            
          
!
            
              var _Graphic;
var _Masking;
var _line;
var _line2;
var _line3;
var _line4;
var _line5;
var _line6;
var _mouse;

var _MaskingContainer1;
var _MaskingContainer2;

var _MaskingAlternative;

// 'Back'
SPF.set({

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

  init: function(PIXI, input) {
   
      _Graphic = new PIXI.Graphics()
        
          input.container.addChild(_Graphic);

        
      
  },
  
  resize :function(PIXI, input) {

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

                _Graphic.clear();
                _Graphic.beginFill(input.colors[18], 1);
                _Graphic.drawRect(0,0,w,h);
                _Graphic.endFill();
  },

  render: function(PIXI, input) {
    //  This is called on every frame, put your animation here
  },
  

});

// 'Mid'
SPF.set({
  
  at: 'mid',
  
  init: function(PIXI, input) {
      
      _MaskingContainer1 = new PIXI.Container()
      _MaskingContainer2 = new PIXI.Container()
      input.container.addChild(_MaskingContainer1);
      input.container.addChild(_MaskingContainer2);
    
      _Masking = new PIXI.Graphics()
      _line = new PIXI.Graphics()   
      _line2 = new PIXI.Graphics()
      _line3 = new PIXI.Graphics()
      _MaskingContainer1.addChild(_Masking)
      _MaskingContainer1.addChild(_line)
      _MaskingContainer1.addChild(_line2)
      _MaskingContainer1.addChild(_line3)
      
      _MaskingAlternative = new PIXI.Graphics();
      _line4 = new PIXI.Graphics()   
      _line5 = new PIXI.Graphics()
      _line6 = new PIXI.Graphics()
      _MaskingContainer2.addChild(_MaskingAlternative)
      _MaskingContainer2.addChild(_line4)
      _MaskingContainer2.addChild(_line5)
      _MaskingContainer2.addChild(_line6)
      
      

      SPF.midgroundMask(true);
      
  },
  
            mouseDownTouchStart: function(PIXI, input) {
                SPF.midgroundMask(false);
                _MaskingContainer2.visible = !_MaskingContainer2.visible;
            },

            mouseUpTouchEnd: function(PIXI, input) {
                SPF.midgroundMask(true);
            },
            
            isTouchDeviceStart: function(PIXI, input) {
                SPF.midgroundMask(false);
            },
            
            isTouchDeviceEnd: function(PIXI, input) {
                SPF.midgroundMask(True);
            },
                      
  
           resize :function(PIXI, input) {

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

               _Masking.clear();
               _Masking.beginFill(input.colors[12], 1);
               _Masking.lineStyle(20, 0xffffff, 1);
               _Masking.drawRect(0,0,w,h);
               _Masking.endFill();
               
               _line.clear();
               _line.beginFill(0xFFFFFF);
               _line.drawRect(w * 0.25, 0, 10, input.height);
               _line.endFill();
             
               _line2.clear();
               _line2.beginFill(0xFFFFFF);
               _line2.drawRect(w * 0.497, 0, 10, input.height);
               _line2.endFill();
             
               _line3.clear();
               _line3.beginFill(0xFFFFFF);
               _line3.drawRect(w * 0.75, 0, 10, input.height);
               _line3.endFill();
                            
                //Alternative
               _MaskingAlternative.clear();
               _MaskingAlternative.beginFill(0xff0000, 1);
               _MaskingAlternative.lineStyle(20, 0x000000, 1);
               _MaskingAlternative.drawRect(0,0,w,h);
               _MaskingAlternative.endFill();
             
               _line4.clear();
               _line4.beginFill(0x000000);
               _line4.drawRect(w * 0.25, 0, 10, input.height);
               _line4.endFill();
             
               _line5.clear();
               _line5.beginFill(0x000000);
               _line5.drawRect(w * 0.497, 0, 10, input.height);
               _line5.endFill();
             
               _line6.clear();
               _line6.beginFill(0x000000);
               _line6.drawRect(w * 0.75, 0, 10, input.height);
               _line6.endFill();
           },
  
});

// 'Fore'
SPF.set({
  
  at: 'fore',
  
  init: function(PIXI, input) {
    
      // Initialize the pixi Graphics class
      _mouse = new PIXI.Graphics();

      // Set the fill color
      _mouse.beginFill(0xffffff); // Red

      // Draw a circle
      _mouse.drawCircle(0, 0, 5); // drawCircle(x, y, radius)
      

      // Applies fill to lines and shapes since the last call to beginFill.
      _mouse.endFill();

      // Add the graphics to the stage
      input.container.addChild(_mouse);
    

  },
 
  
  render: function(PIXI, input) {
    
      _mouse.x = input.mouseTouchPosition.x;
      _mouse.y = input.mouseTouchPosition.y;
    
    
    // fade with music
    //  var v = input.audio.frequencies()[100];
    //  _mouse.alpha = v / 200;
    
    //Fade pulsating
    var fadeSpeed = 4;
    var fade = Math.sin(input.currentTime * fadeSpeed) * 0.5 + 0.5;
    _mouse.alpha = fade;
    
    /*if (input.currentTime == null || input.currentTime <= 5) {
      
      // Get the frequency 100
      var v = input.audio.frequencies()[100];

      // Set the alpha of the square background as the
      // frequency divided by 200
      _mouse.alpha = v / 200;
        
    } else {
      
      _mouse.clear();
    
      _mouse.beginFill(input.colors[2]);
      
      _mouse.drawRect(0, 0, input.width, input.height);
    
      _mouse.endFill();
      
    },*/
    
  },

  
});

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