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

            
          
!
            
              var background
var sprite
var figures
var curFraming; // updates every time the framing is changed
var spriteArray = [];
var objectArray = [];
var maskActive = false;
var curCast;
var fallingSprite;
var allGraphics;
// Background color
SPF.set({

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


  init: function(PIXI, input) {
    
    //  Draw you graphics in PIXI adding them to input.container
    
    
    
    background = new PIXI.Graphics();
    console.log(Object.keys(background))
    
    background.beginFill(input.colors[8]);
    background.drawRect(0,0,input.width, input.height)
    background.endFill();
    
    input.container.addChild(background);
    
    /*var text 
    
    text = new PIXI.Text('SCARLET PLEASURE', {fontFamily : 'Arial Black', fontSize: 100, fill :input.colors[18], align : 'center'});
    text.anchor.set(0.5);

    

    input.container.addChild(text);*/
 
  },
   

  render: function(PIXI, input) {
    //  This is called on every frame, put your animation here
    // Set random color when framing changes
    var thisFraming = input.editing ;
    if(!(thisFraming===curFraming)){
      curFraming = thisFraming
      randNum    = Math.floor( Math.random()*input.colors.length ) // Calculate random color between 0-numberOfAvailableColors
      randomCol  = input.colors[ randNum ] // Get random color from presets
      // Change the background's color
      background.clear();
      background.beginFill(randomCol,1);
      background.drawRect(0,0,input.width, input.height)
      background.endFill();
    }
  }
  

});

// Foreground, Beginning reveal + rows in forground
SPF.set({
  
  at: "fore",
  
  init: function(PIXI,input){
   
    
    //rows on top and bottom
    allGraphics = [input.graphics.crazyflower1, input.graphics.crazyflower2, input.graphics.crazyflower3, input.graphics.flower1, input.graphics.flower2, input.graphics.wingwave];
   
    var object;
    
    //distance between each object
    var distX = 40
    var distY = 40
    //for loop of objects
    var i = 0;
    while (distX * i < input.width){
    
      //object = new PIXI.Sprite(input.graphics.botanicorganic);
      var rand = Math.floor(Math.random()*allGraphics.length);
      object = new PIXI.Sprite(allGraphics[rand]);
    
      object.anchor.x = 0.5;
      object.anchor.y = 0.5;
    
      //where the object is placed
      if(i%2 == 0){
        object.position.x = distX*i;
        object.position.y = distY;
      }else{
        object.position.x = (distX*(i-1));
        //distance between rows 
        object.position.y = input.height - distY;
      }
      
      //how big it is
      object.scale.x = 0.2;
      object.scale.y = 0.2;
      
      // add interaction
      object.interactive = true;
      object.on('mouseover', function() {
        this.texture = allGraphics[Math.floor(Math.random()*allGraphics.length)];
      });
    
      input.container.addChild(object);
      
      objectArray.push(object);
      i++;
    };
    
    //falling flowers in different sizes
    var rand = Math.floor(Math.random()*allGraphics.length);
    fallingSprite = new PIXI.Sprite(allGraphics[rand]);
    input.container.addChild(fallingSprite);
    fallingSprite.anchor.x = 0.5;
    fallingSprite.anchor.y = 0.5;
    fallingSprite.scale.x = fallingSprite.scale.y = 0.25;
    fallingSprite. y = input.height* 2;
    //for REVEAL in beginning
    var graphic;
    
    // Generate some sprites
    for (var i = 0; i < 100; i++) {
      // Create a new sprite
      graphic = new PIXI.Sprite(input.graphics.stone);
      
      // Set position randomly on the screen
      graphic.x = Math.random() * input.width;
      graphic.y = Math.random() * input.height;
      
      // Set rotation randomly
      graphic.rotation = Math.random() * 360;
      
      // Set center point of each object
      graphic.anchor.x = 0.5;
      graphic.anchor.y = 0.5;
      
      // Random scale from 0 to 50%
      graphic.scale.x = graphic.scale.y = 0.5 //Math.random() * 0.5    
  
      
      // Add sprite to the container (so we can see it)
      input.container.addChild(graphic);
      
      // Add sprite reference to the array variable
      spriteArray.push(graphic);
    }
    

  },
  
  render: function(PIXI, input) {
    
    //get rows to changes graphic when mouse moves over
    var changeGraphics;
    
    //input.mouseTouchPosition: function(PIXI, input);
    
    
    //REVEAL in beginning
    // We make a variable to save each element of the array
    if (input.currentTime < 3){
      return
    }
    var mySprite;
    var pos;
    var speed = 0.5
    // Loop half the sprites in the array to the right
    for (var i = 1; i <= spriteArray.length; i++) {
      // Get a reference of each sprite
      mySprite = spriteArray[i-1];
      // X position gets 20% of i added
      pos = i * speed + 5
      if (i>spriteArray.length/2){
        pos = -i * speed + 5
      }
      mySprite.x += pos;
      // X position gets 1% of i added
      mySprite.rotation += i * 0.001;
    }
    //falling according to the cast
    var thisCast = input.cast ;
    if(!(thisCast===curCast)){
      curCast = thisCast
      //if(thisCast.id == "all"){
      if(fallingSprite.y > input.height + fallingSprite.height){
        //console.log("falling flower")
        var rand = Math.floor(Math.random()*allGraphics.length);
        fallingSprite.texture = allGraphics[rand];
        fallingSprite.y = -fallingSprite.height;
        fallingSprite.x = Math.random() * input.width;
        fallingSprite.scale.x = fallingSprite.scale.y = 0.1 + Math.random() * 0.25;
      }
    }
    
    //how the flower is falling with a sinus curv
    fallingSprite.y += 3;
    fallingSprite.x += Math.sin(input.currentTime) * 2;
    fallingSprite.rotation += 0.01;
  }
});

// Midground graphics (on top of band)
SPF.set({
  
  at: "mid",
  
  init: function(PIXI,input){
    var sizeX = input.width
    var sizeY = input.height
    
    //opretter et billede, og bestemmer stoelse
    sprite = new PIXI.extras.TilingSprite(input.maskers.handdrawnanimal1, sizeX, sizeY)
    sprite.visible = false;
    //SPF.midgroundMask(true);
    //sprite.visible = false
    input.container.addChild(sprite);
      

  },
  
  render: function(PIXI, input) {
    
    //SPF.midgroundMask(false);
  },
  
  mouseDownTouchStart: function(PIXI, input){
  
    //if the mask is off, its not visable and we remove the mask as well
    if (maskActive) {
      maskActive = false;
      sprite.visible = false;
      SPF.midgroundMask(false);
   //if the mask is on, it needs to be visable and we add the mask again
    } else {
      maskActive = true;
      sprite.visible = true;
      SPF.midgroundMask(true);
    }
  
  },
  


  
  
});


SPF.start();
            
          
!
999px
Loading ..................

Console