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

              
                <svg class="canvas" viewBox="0 0 200 200">
  <defs>
    <linearGradient id="black" gradientTransform="rotate(90)">
      <stop offset="0" stop-color="#0000" />
      <stop offset="0.49" stop-color="#0000" />
      <stop offset="0.5" stop-color="#1f272f" />
      <stop offset="1" stop-color="#1f272f" />
    </linearGradient>
    <linearGradient id="purple" gradientTransform="rotate(90)">
      <stop offset="0" stop-color="#fc00ff" />
      <stop offset="1" stop-color="#00dbde" />
    </linearGradient>
    <linearGradient id="pink" gradientTransform="rotate(90)">
      <stop offset="0" stop-color="#c26fdd" />
      <stop offset="1" stop-color="#f0bd50" />
    </linearGradient>
    <linearGradient id="blue" gradientTransform="rotate(90)">
      <stop offset="0" stop-color="#4ff0ea" />
      <stop offset="1" stop-color="#683df0" />
    </linearGradient>

    <filter id="noise2" x="-100" y="-100" width="400" height="400">
      <feTurbulence type="fractalNoise" baseFrequency="5" numOctaves="3" stitchTiles="stitch" />
      <feDisplacementMap in="SourceGraphic" scale="800" xChannelSelector="R" yChannelSelector="G" />
    </filter>

    <filter id="noiseHeavy" x="-50" y="-50" width="300" height="300">
      <feTurbulence id="freq" type="fractalNoise" baseFrequency="0.7" numOctaves="0.1" stitchTiles="stitch" />
      <feDisplacementMap in="SourceGraphic" scale="170" xChannelSelector="G" yChannelSelector="G" />
    </filter>
    <mask id="maskedHeavyNoise">
      <rect cx="0" cy="0" width="200" height="200" fill="white" filter="url(#noiseHeavy)"></rect>
    </mask>

    <filter id="noise" x="-50" y="-50" width="300" height="300">
      <feTurbulence type="fractalNoise" baseFrequency="3" numOctaves="3" stitchTiles="stitch" />
      <feDisplacementMap in="SourceGraphic" scale="300" xChannelSelector="G" yChannelSelector="G" />
    </filter>
    <mask id="maskedNoise">
      <rect cx="0" cy="0" width="200" height="200" fill="white" filter="url(#noise)"></rect>
    </mask>
  </defs>
</svg>

<button class="refresh" data-content="new sketch pls">new sketch pls</button>
              
            
!

CSS

              
                * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d8d4cc;
  flex-direction: column;
}

.canvas {
  width: 75vmin;
  height: 75vmin;
  max-width: 400px;
  max-height: 400px;
  background: #eee2d5;
  box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;
}

button {
  margin-top: 1rem;
  background-color: #eee2d5;
  display: inline-block;
  position: relative;
  padding: 0.5rem 1.25rem;
  background-color: #1f272f;
  text-decoration: none;
  letter-spacing: 0.02em;
}

button:after {
  box-sizing: border-box;
  position: absolute;
  content: attr(data-content);
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-color: #d8d4cc;
  color: #1f272f;
  border: solid 2px #1f272f;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-0.1rem, -0.1rem);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

button:hover:after {
  transform: translate(0, 0);
}

              
            
!

JS

              
                import { SVG } from "https://cdn.skypack.dev/@svgdotjs/svg.js";

const svg = SVG(".canvas");
const g = svg.group();
const u = gsap.utils;
const { width, height } = svg.viewbox();
const numStripes = 20;
const spacing = width / numStripes;

function generate() {
  g.clear();
  let grid = g.group();
  grid.attr("opacity", 0.2);

  for (let i = 0; i < width; i += spacing) {
    grid
      .line(i, 0, i, height)
      .stroke({ color: "#1f272f", width: 0.5, linecap: "round" });
    grid
      .line(height, i, 0, i)
      .stroke({ color: "#1f272f", width: 0.5, linecap: "round" });
  }

  let firstCircle = {
    x: u.random(0, width - 100),
    y: u.random(0, height - 100),
    r: u.random(120, 180, 5)
  };
  g.circle(firstCircle.r)
    .move(firstCircle.x, firstCircle.y)
    .attr("mask", "url(#maskedHeavyNoise)")
    .attr("fill", "url(#black)")
    .attr("class", "semi");

  let squares = g.group();
  squares.attr("class", "squares");
  let maxSquares = 26;

  for (let i = 0; i < maxSquares; i++) {
    squares
      .rect(spacing, spacing)
      .fill("#1f272f")
      .move(u.random(0, width, spacing), u.random(0, width, spacing));
  }

  let mess = g
    .rect(width, width)
    .fill("#000")
    .attr("filter", "url(#noise2)")
    .opacity(0.1);

  let lines = g.group();
  lines.attr("mask", "url(#maskedNoise)").attr("class", "pattern");
  let picker = u.random(0, 6, 1);
  for (let i = 0; i < width; i += spacing) {
    let line;
    switch (picker) {
      case 0:
        line = lines.line(i, i, 0, height);
        break;
      case 1:
        line = lines.line(0, 0, i, height);
        break;
      case 2:
        line = lines.line(i, i, i, height);
        break;
      case 3:
        line = lines.line(0, height, i, i);
        break;
      case 4:
        line = lines.line(i, 0, height, i);
        break;
      case 5:
        line = lines.line(i, height, 0, i);
        break;
      case 6:
        line = lines.line(i, height, height, i);
        break;
    }
    line.stroke({ color: "#1f272f", width: 0.5, linecap: "round" });
  }

  let noOfRects = u.random(1, 5);
  let rectX = u.random(0, width - 50);
  let rectY = u.random(0, width - 50);
  let rectW = u.random(20, width / 2.3);
  let rectH = u.random(20, width / 2.3);
  let screens = g.group().attr("class", "screens");

  for (let i = 0; i < noOfRects; i += 1) {
    var rect = screens
      .rect(rectH, rectW)
      .move(rectX, rectY)
      .stroke("#1f272f")
      .fill("#eee2d5");

    rectX += 5;
    rectY -= 5;
  }

  let circles = [];

  function doesCircleHaveACollision(circle) {
    for (var i = 0; i < circles.length; i++) {
      var otherCircle = circles[i];
      var a = circle.r + otherCircle.r;
      var x = circle.x - otherCircle.x;
      var y = circle.y - otherCircle.y;

      if (a >= Math.sqrt(x * x + y * y)) {
        return true;
      }
    }
  }

  let maxTries = 50;
  let tries = 0;

  while (tries <= maxTries) {
    let newCircle = {
      x: u.random(-50, width - 20),
      y: u.random(-50, height - 20),
      r: u.random(10, 60, 5)
    };

    if (!doesCircleHaveACollision(newCircle)) {
      circles.push(newCircle);
      g.circle(newCircle.r)
        .move(newCircle.x, newCircle.y)
        .attr("mask", "url(#maskedHeavyNoise)")
        .attr("fill", `url(#${u.random(["purple", "pink", "blue"])})`);
    } else {
      // g.circle(newCircle.r)
      //   .move(newCircle.x, newCircle.y)
      //   .attr("fill", 'black');
    }
    tries++;
  }
}

generate();
animate();

function animate() {
  gsap.set(".semi", {
    rotate: "random([90, -90, 0])",
    transformOrigin: "center"
  });

  let t = gsap.timeline({ delay: 0.3, defaults: { ease: "sine.out" } });

  t.from([".screens > *", "circle"], {
    opacity: 0,
    duration: 1
  })
    .from(".pattern > *", { stagger: 0.1, drawSVG: 0 })
    .from(
      ".squares > *",
      {
        opacity: 0,
        stagger: 0.05,
        transformOrigin: "center",
        duration: 0.1
      },
      0.5
    );
}

let refresh = document.querySelector("button");
refresh.addEventListener("click", (e) => {
  generate();
  animate();
});

              
            
!
999px

Console