Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<div class="attribute">
    <h3>CIRCLES IN PIXI.JS</h3>
    <h5>PEN BY: NISAIFUDEEN</h5>
  </div>
  <div>
    <canvas id="my-canvas" width="500" height="500"></canvas>
  </div>
              
            
!

CSS

              
                /*
* Support css styles,
* for background and text
*
*
*
*
*/







@import url('https://fonts.googleapis.com/css?family=Big+Shoulders+Text&display');

 body {
      /* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#0e0701+0,3e2100+44,0e0701+100 */
      background: #0e0701;
      /* Old browsers */
      background: -moz-linear-gradient(left, #0e0701 0%, #3e2100 44%, #0e0701 100%);
      /* FF3.6-15 */
      background: -webkit-linear-gradient(left, #0e0701 0%, #3e2100 44%, #0e0701 100%);
      /* Chrome10-25,Safari5.1-6 */
      background: linear-gradient(to right, #0e0701 0%, #3e2100 44%, #0e0701 100%);
      /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
      filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0e0701', endColorstr='#0e0701', GradientType=1);
      /* IE6-9 */

    }

    body,
    * {
      padding: 0;
      margin: 0;
    }

    h3 {
      /* font-family: 'Staatliches', cursive; */
      font-size: 30px;
      color: #ffffff;
      font-family: 'Big Shoulders Text', cursive;
    }

    h5 {
      color: #f69999;
      font-family: 'Big Shoulders Text', cursive;
    }

    .attribute {
      position: fixed;
      top: 50%;
      left: 50%;
      width: 500px;
      transform: translate(-50%, -50%);
      -webkit-transform: translate(-50%, -50%);
      -moz-transform: translate(-50%, -50%);
      text-align: center;
      z-index: -1;

    }
              
            
!

JS

              
                 /* PIXI.JS circles */
    /* Author: Saifudeen */
    /* Pen: nisaifudeen*/
    $(document).ready(function () {
     // Global variables
      let type = "WebGL",
        Application = PIXI.Application,
        Graphics = PIXI.Graphics,
        Container = PIXI.Container,
        winWidth = window.innerWidth,
        winHeight = window.innerHeight,
        /* ********************************************** */  
        count = 400, //Circle's count
        /* ********************************************** */
        winValue,
        toTop = false,
        toBottom = false,
        toTopLeft = false,
        toTopRight = false,
        toBottomLeft = false,
        toBottomRight = false;

      const my = window.innerHeight / 2,
        mw = window.innerWidth / 2;


      //basic pixi support
      if (!PIXI.utils.isWebGLSupported()) {
        type = "canvas";
      }

      //Base PIXI app
      let app = new Application(winWidth, winHeight, {
          view: document.getElementById('my-canvas'),
          transparent: true,
          antialias: true
        }),

        //Container
        container = new Container(),
        circle;
      app.stage.addChild(container);
      container.interactive = true;

      for (i = 0; i <= count; i++) {
        rad = Math.floor(Math.random() * 60); //Radius
        xVal = Math.floor(Math.random() * winWidth); //Left value
        yVal = Math.floor(Math.random() * winHeight); //Top value
        //generateBubble(Radius, left value, top value)
        generateBubble(rad, xVal, yVal);
      }

      function generateBubble(rad, xVal, yVal) {
        //Bubbles
        circle = new Graphics();
        circle.lineStyle(1, 0xe5bf17);
        circle.beginFill(0x000000, 0);
        circle.drawCircle(xVal, yVal, rad);
        circle.interactive = true;
        circle.endFill();
        container.addChild(circle);
      }

      //Bubble float
      function bubbleFloat() {
        for (j = 0; j <= count; j++) {
          //Added TweenMax animation
          TweenMax.to(circle.parent.children[j], 60, {
            pixi: {
              x: "+=" + (Math.random() * 300),
              y: "+=" + (Math.random() * 200)
            },
            repeat: -1,
            yoyo: true
          });

        }
      }

      bubbleFloat();
     
      container.mousemove = function (v) {
        circle.parent.children.forEach(function (e) {
          e.mouseover = function (currentCircle) {
            let clientXInside = currentCircle.data.originalEvent.clientX,
              clientYInside = currentCircle.data.originalEvent.clientY;
            
            if (clientXInside < mw) {
              if (clientYInside < my) {
                //Left top area
                // bubbleMove(element, time, x value, y value, x+=, y-=); for tweenmax
                bubbleMove(currentCircle.target, 0.9, 200, 100, 1, 1);
              } else {
                //Left bottom area
                // bubbleMove(element, time, x value, y value, x+=, y-=); for tweenmax
                bubbleMove(currentCircle.target, 0.9, 200, 100, 1, -1)
              }
            } else {
              if (clientYInside < my) {
                //Right top area
                // bubbleMove(element, time, x value, y value, x+=, y-=); for tweenmax
                bubbleMove(currentCircle.target, 0.9, 200, 100, -1, 1)
              } else {
                //Right bottom area
                bubbleMove(currentCircle.target, 0.9, 200, 100, -1, -1)
              }

            }

          }
        })
      }

      function bubbleMove(elem, t, xV, yV, posX, posY) {
        elem.tint = 0x00ff00;
        TweenMax.to(elem, t, {
          pixi: {
            x: "+=" + (Math.random() * (xV * posX)),
            y: "+=" + (Math.random() * (yV * posY))
          }
        });

        setTimeout(function () {
          elem.tint = 0xe5bf17;

        }, 1000)
      }

      document.ondblclick = function () {
        circle.parent.children.forEach(function (e) {
          TweenMax.to(e, 0.7, {
            pixi: {
              x: (Math.random() * 100),
              y: (Math.random() * 100)
            }
          });
        });
      }
    })
              
            
!
999px

Console