Pen Settings

HTML

CSS

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

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

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.

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

              
                    <svg class="site-bg__prism" viewBox="0 0 1044 1006" fill="none" xmlns="http://www.w3.org/2000/svg">
        
<path opacity="0.1" d="M514.866 109.292L438.382 14.8205L350.185 0.444092L288.748 14.7573L211.834 21.9358L127.705 19.2287L60.4896 58.5935L0.649414 171.596L6.45021 361.159L84.8981 469.475L180.303 502.738L312.331 475.688L385.241 432.514L449.25 354.119L494.213 260.279L521.272 162.775L514.866 109.292Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)"/>
            <path opacity="0.2" d="M455.868 255.512L464.687 152.614L448.838 96.1473L391.329 38.7099L197.838 37.3079L95.7332 54.7909L4.70752 210.801L27.3383 362.114C27.3383 362.114 109.838 457.628 107.337 456.479H296.338L434.338 314.114L455.868 255.512Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)"/>
            <path opacity="0.3" d="M402.586 295.972L409.891 151.972L366.586 83.9716L250.086 61.4716L123.586 61.4716L22.5864 193.972L77.0864 412.972L244.586 439.972L402.586 314.972V295.972Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)" stroke="url(#prism-stroke)"/>
            <path opacity="0.4" d="M360.932 328.762L358.099 147.269L249.38 91.3844L153.889 77.351L37.5862 176.972L55.9904 384.147L195.667 422.738L348.275 345.182L360.932 328.762Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)"/>
            <path opacity="0.5" d="M323.95 304.021L304.092 148.712L206.901 110.288L125.052 106.567L43.7476 195.102L72.3455 378.019L193.851 398.916L323.95 314.972V304.021Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)"/>
            <path opacity="0.6" d="M297.338 299.114L279.613 165.114L185.392 131.765L116.586 127.101L49.8015 205.165L76.8651 369.824L179.267 390.602L279.613 321.005L297.338 299.114Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)"/>
            <path d="M271.338 263.472L246.113 168.411L174.338 138.972L118.586 144.972L66.0864 201.972L96.0864 346.472L174.338 373.472L271.338 306.972V263.472Z" fill="url(#prism-gradient)" stroke="url(#prism-stroke)"/>
    </svg>

<div class="controls">
  <button class="expand">Expand</button>
  <button class="reduce">Reduce</button>
</div>
              
            
!

CSS

              
                body {
  background: #000;
}

.controls {
  position:relative;
  z-index:1000;
}
              
            
!

JS

              
                  let two = new Two({
    autostart: true,
    fullscreen:true,
    type: Two.Types.canvas,
    ratio: window.devicePixelRatio > 1 ? 1.5 : 1,
  }).appendTo(document.body);

  let svg = document.querySelector(".site-bg__prism");
  svg.style.display = "none";

  let linearGradient = new Two.LinearGradient(400, 100, 100, 400, [
    new Two.Stop(0, "#3850CF"),
    new Two.Stop(1, "#00FFEE")
  ]);

  two.add(linearGradient);

  let prism = two.interpret(svg);

  prism.center();
  prism.fill = linearGradient.clone();
  prism.noStroke();


  two.bind("resize", function() {
    let aspect = two.width / two.height;

    prism.translation.set(two.width / 2, two.height / 2);

    if (aspect < 1) { prism.scale = aspect; }
  });

  two.trigger("resize")

  function scalePrism(scaleFactor, style) {
    
//     let cX = prism.children[6].getBoundingClientRect().width / 2,
//         cY = prism.children[6].getBoundingClientRect().height / 2
        
//     TweenMax.to(prism.children[6], 0.3, {scale:scaleFactor})
    
//     let cXs = prism.children[6].getBoundingClientRect().width / 2,
//         cYs = prism.children[6].getBoundingClientRect().height / 2
    
//     TweenMax.to(prism.children[6].translation, 0.3, {
//       x:  prism.children[6].translation.x - (cXs - cX),
//       y:  prism.children[6].translation.y - (cYs - cY)
//     })
 
    
//     prism.children.forEach((el, i) => {
//       TweenMax.to(el, 0.3,
//         {
//           scale: scaleFactor,
//           delay: i / 50,
//           linewidth: 1 - (1 / scaleFactor),
//           onUpdate: () => { prism.center() },

//         }, "s1");
//     });

    let tl = new TimelineMax({ 
      onComplete: () => { changeStyleTo(style) } 
    })

    tl.staggerTo(prism.children, 0.3, { scale: scaleFactor }, 0.03)
    
  }

  function changeStyleTo(style) {

    if(style == 'fill') {
      new TimelineMax()
        .call(() => prism.noStroke())
        .to(prism.fill.stops[0], 0.3, {color: '#3850CF'}, 's1')
        .to(prism.fill.stops[1], 0.3, {color: '#00FFEE'}, 's1')  
    }

    if(style == 'stroke') {
      new TimelineMax()
        .call(() => {prism.stroke = linearGradient}, 's1')
        .to(prism.fill.stops[0], 0.3, {color: '#000'}, 's1')
        .to(prism.fill.stops[1], 0.3, {color: '#000'}, 's1')
    } 
    
  }

  document.querySelector('.expand').addEventListener("click", () => { 
    scalePrism(1.2, 'stroke')
  });

  document.querySelector('.reduce').addEventListener("click", () => { 
    scalePrism(1, 'fill')
  });
              
            
!
999px

Console