css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

  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

  at: 'back',
//load function start:
  load: function(PIXI, input) {
    return [];

//init function start  
  init: function(PIXI, input) {
//draw background
    background = new PIXI.Graphics();
    background.drawRect(0, 0, input.width, input.height);
//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[i % input.colors.length]);
        rect.drawRect(-rectSize/2, -rectSize/2, rectSize, rectSize);   
        rect.x = x + rectSize/2;
        rect.y = y + rectSize/2;
        i += 1;
//resizing background
    resize: function (PIXI, input) {
      background.drawRect(0, 0, input.width, input.height);
//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.drawRect(-w/2, -h/2, w, h);

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

  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);  
    //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'});
    backgroundColor = input.colors[15];
//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;
//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) {

    debug: false,
    title: "Mathias Jørgensen",
    firstName: "Mathias",
    lastName: "Jørgensen",
    email: "mkmathiasj@gmail.com",
    section: "s4, s7, s9"


🕑 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 ..................