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.

Quick-add: + add another resource

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.

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;
}

            
          
!
            
              //global variables
var instructtext
var rect
var circle
var rects = [];
var background
var rectSize = 100;
var rectDist = 20;
var rect_bottom

//set-start
SPF.set({
  at: 'back',
  
//load function start:
  load: function(PIXI, input) {
    return [];
  },

//init function start  
  init: function(PIXI, input) {
   
//draw background
    background = new PIXI.Graphics();
    background.beginFill(0xffffff);
    background.drawRect(0, 0, input.width, input.height);
    background.endFill();
    input.container.addChild(background);
   
//draw squares on background
    var i = 0;
    for(var y = 0; y<input.height; y+= rectSize + rectDist){
      for(var x = 0; x<input.width; x+= rectSize + rectDist){  
        rect = new PIXI.Graphics();
        rect.beginFill(input.colors[9]);
        rect.beginFill(input.colors[i % input.colors.length]);
        rect.drawRect(-rectSize/2, -rectSize/2, rectSize, rectSize);   
        rect.x = x + rectSize/2;
        rect.y = y + rectSize/2;
        rect.endFill();
        input.container.addChild(rect);
        i += 1;
        rects.push(rect);        
      }
    }    
  },
   
//resizing background
    resize: function (PIXI, input) {
      background.clear();
      background.beginFill(0xffffff);
      background.drawRect(0, 0, input.width, input.height);
      background.endFill();
  },
    
//random colors for squares by mouse touch 
    mouseDownTouchStart: function(PIXI, input) {
    
//variables for background square colors 
   var myRect;
   var w;
   var h;
   var color;
      
//draw new colors to squares when mouse touch down      
    for (var i = 0; i < rects.length; i++) {
      color = input.colors[Math.floor(Math.random() * input.colors.length)];
      myRect = rects[i];
      w = myRect.width;
      h = myRect.height;
      myRect.clear();
      myRect.beginFill(color);
      myRect.drawRect(-w/2, -h/2, w, h);
      myRect.endFill();
    }
  },

//render function start
  render: function(PIXI, input) {
     
//rotating rectangles with mouse
    var r 
    var myRect;
    for (var i = 0; i < rects.length; i++) {
      myRect = rects[i];
      r = input.mouseTouchPosition.x/500
      myRect.rotation = r
      myRect.scale.x = myRect.scale.y = 0.3 + input.mouseTouchPosition.y/700
          
//audio reactive rectangles
      var v = input.audio.frequencies()[600];
        myRect.alpha = v / 180;   
    }  
  }  
});

//variables for foreground
var text
var imageSprite

SPF.set({   
  at: 'fore',
  
//init function start  
  init: function(PIXI, input) {
    
    
//adding bottom sprite    
    var texture = PIXI.Texture.fromImage('https://lh3.googleusercontent.com/p55pQyUZeR9JKYp-AocXlTC5n0djOWJ9UJonNme_wvvasVyGM0eiK02oQCp0I-idyfR1fVOWifiCygY=w2560-h1316-rw');
    imageSprite = new PIXI.Sprite(texture);  
    input.container.addChild(imageSprite);
    //imageSprite.y = 400;
    console.log(input.height - imageSprite.height);
    imageSprite.y = (input.height / 2) - imageSprite.height;
    
//adding text    
    text = new PIXI.Text('move and click your\n mouse to interact', {fontFamily : 'Arial Black', fontSize: 10, fill: input.colors[10], align : 'center'});
    text.anchor.set(0.5);
    backgroundColor = input.colors[15];
    input.container.addChild(text);
   },
  
//remove text when mouse click  
   mouseDownTouchStart: function(PIXI, input) {
     text.visible = false
   },
  
//resize bottom sprite with canvas  
   resize: function(PIXI, input) {
     imageSprite.y = (input.height) - imageSprite.height;
     console.log(imageSprite.height);
     
//resize ntext with canvas
     text.position.set(input.width/2, input.height/2);
     text.style.fontSize = input.width/50;
   },

//render function start  
   render: function(PIXI, input) {
  }  
});

//information
SPF.info({
    debug: false,
    title: "Mathias Jørgensen",
    firstName: "Mathias",
    lastName: "Jørgensen",
    email: "mkmathiasj@gmail.com",
    section: "s4, s7, s9"
});

SPF.start();

//END
            
          
!
999px
Loading ..................

Console