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

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

              
                %h1 DAN <br>FLASHES<span>Complicated Shirts <br>for Complicated Gentlemen</span>
%span fetching new shirts
%strong click for new shirt
#pattern
 -64.times do
  .cell
   %svg{:viewbox => "0 0 400 400", :xmlns => "http://www.w3.org/2000/svg"}
    %path.cellsvg1{ :stroke => "#FF0066", :fill => "transparent"}
    %path.cellsvg2{ :stroke => "#FF0066", :fill => "transparent"}
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Playfair+Display:[email protected]&display=swap");

body {
  font-family: "Playfair Display", serif;
  background: #fff;
  height: 100vh;
  --cellcount: 10;
  overflow: hidden;
  cursor: pointer;
  * {
    cursor: pointer;
  }
  transform: scale(0.75);
  @media (max-width: 1000px) {
    transform: scale(0.5);
  }
  &:before,
  &:after {
    content: "";
    position: absolute;
    width: 900px;
    height: 900px;
    left: calc(50% - 450px);
    top: calc(50% - 450px);
    box-shadow: inset 0 0 0 25px #f0e6d2, inset 0 0 0 26px #fff,
      0 40px 60px -40px rgba(0, 0, 0, 0.25);
    background: radial-gradient(
      circle at center,
      lighten(#f0e6d2, 5%),
      #f0e6d2 90%
    );
  }
  &:after {
    background: transparent;
    z-index: 999;
    box-shadow: 0 40px 60px -40px rgba(0, 0, 0, 0.25), 0 0 0 125vw #fff;
  }
  h1 {
    position: absolute;
    z-index: 1;
    color: #222;
    font-weight: 900;
    font-size: 40px;
    display: inline-block;
    left: calc(50% - 250px);
    top: calc(50% - 350px);
    transform: translate(-50%, -50%);
    transition: 1s ease-in-out;
    transition-delay: 0.5s;
    span {
      font-size: 20px;
      color: #666;
      display: block;
      margin-top: 0.15rem;
    }
  }
  > span {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #222;
    font-size: 12px;
    transition: opacity 0.5s ease-in-out;
    opacity: 0;
    &:before {
      content: "(complicated shirts take time)";
      position: absolute;
      left: 50%;
      top: 125%;
      transform: translateX(-50%);
      width: 300px;
      text-align: center;
      opacity: 0.5;
    }
    &:after {
      content: ".....";
      animation: loading 2s linear infinite;
      position: absolute;
      left: 100%;
      clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
      @keyframes loading {
        100% {
          clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
        }
      }
    }
  }
  > strong {
    position: absolute;
    z-index: 10;
    top: calc(50% + 400px);
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1;
    transition: 0.5s ease-in-out;
    transition-delay: 2s;
  }
  &.loading {
    > strong {
      opacity: 0;
      transition-delay: 0s;
    }
    > span {
      opacity: 1;
    }
    canvas {
      transform: translateY(clamp(800px, 100vh, 90000px));
    }
  }
  canvas {
    z-index: 2;
    position: relative;
    transition: transform 1s cubic-bezier(0.175, 0.885, 0.32, 1.075);
    filter:contrast(calc(1 + (var(--contrast)/7)));
  }
  #pattern {
    overflow: hidden;
    position: absolute;
    width: 1200px;
    height: 1200px;
    left: -2400px;
    top: 0;
    z-index: 999;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    grid-column-gap: 0px;
    grid-row-gap: 0px;
    z-index: -1;
    &:before {
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      z-index: 10;
      background: linear-gradient(
          to left,
          var(--color1),
          transparent,
          var(--color1)
        ),
        linear-gradient(to bottom, var(--color2), transparent, var(--color2));
    }
    .cell {
      background: transparent;
      position: relative;
      z-index: -1;
      background: radial-gradient(
          circle at center,
          var(--color1) 15px,
          transparent 5px
        ),
        linear-gradient(
          var(--rotate2),
          transparent 50%,
          var(--color0) 50%,
          var(--color4) 100%
        ),
        linear-gradient(var(--rotate2), var(--color2), transparent);
      background-position: calc(var(--rotate) * 0.5px)
          calc(var(--rotate) * 0.5px),
        calc(var(--rotate) * 2px) calc(var(--rotate) * 2px);
      &:before,
      &:after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 100%;
        background: linear-gradient(45deg, var(--color6), var(--color7));
        transform: scale(calc(1 - (var(--scale) / 4)));
      }
      &:after {
        background: radial-gradient(
          circle at bottom,
          transparent 25%,
          var(--color8) 25%,
          var(--color8) 35%,
          transparent 35%
        );
        border-radius: 0px;
        transform: scale(calc(var(--scale) / 10)) rotate(var(--rotate2));
      }
      svg {
        position: absolute;
        width: 100%;
        height: 100%;
        left: 0;
        top: 0;
        z-index: 2;
        background: radial-gradient(
              circle at center,
              var(--color1) 2px,
              transparent 2px,
              transparent
            )
            50% 50% / calc(var(--distance2) * 1px) calc(var(--distance2) * 1px),
          repeating-linear-gradient(
            var(--rotate2),
            var(--color5) 1px,
            transparent 1px,
            transparent calc(var(--distance) * 1px),
            var(--color5) calc(var(--distance) * 1px),
            var(--color5) calc((var(--distance) * 1px) + 1px)
          ),
          repeating-linear-gradient(
            calc(var(--rotate2) * 90),
            var(--color5) 1px,
            transparent 1px,
            transparent 5px,
            var(--color5) 5px,
            var(--color5) 6px
          );
        path {
          stroke-width: var(--stroke);
          stroke: var(--color3);
        }
      }
    }
  }
}

              
            
!

JS

              
                var imageURL;
var shirt;
var colors = ["", "", "", "", "", "", "", "", ""];
var img = "";
var paths1 = [
  "M 200 400 C 200 310 190 280 260 200 C 330 140 310 210 400 200 ",
  "M 200 400 C 200 310 190 280 290 310 C 390 340 310 190 400 200 ",
  "M 200 400 C 200 330 150 330 230 290 C 370 220 210 80 130 160 Q 30 260 160 310 C 290 390 210 190 400 200 "
];
var paths2 = [
  "M 0 200 C 180 190 190 280 230 230 C 260 180 190 150 200 0 ",
  "M 0 200 C 90 210 60 160 160 200 C 310 250 210 100 200 0 ",
  "M 0 200 C 90 210 60 160 30 120 C 0 60 210 100 200 0 ",
  "M 0 200 C 90 210 20 310 100 280 C 310 250 210 100 130 160 Q 40 240 160 310 C 290 390 380 230 200 0 "
];
var pattern = document.getElementById("pattern");
document.body.classList.add("loading");
drawShirt();

function preload() {
  shirt = loadModel("https://assets.codepen.io/383755/shirt.obj", true);
}

function setup() {
  reset();
}

function reset() {
  createCanvas(windowWidth, windowHeight, WEBGL);
  img = loadImage(imageURL);
}

function draw() {
  background(255, 255, 255, 0);
  ambientLight(180);
  directionalLight(255, 255, 255, width / 2, height / 2, 0);
  rotateY(frameCount / 40);
  noStroke();
  rotateX(15.6);
  scale(2, 2, 2);
  model(shirt);
  texture(img);
  textureMode(IMAGE);
  textureWrap(CLAMP);
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

function drawShirt() {
  document.body.style.setProperty("--contrast", Math.floor(Math.random() * 10));
  pattern.style.setProperty("--cellcount", Math.floor(Math.random() * 3) + 7);
  pattern.style.setProperty("--stroke", Math.floor(Math.random() * 25) + 5);
  pattern.style.setProperty(
    "--color1",
    "rgba(" +
      Math.floor(Math.random() * 255) +
      "," +
      Math.floor(Math.random() * 255) +
      "," +
      Math.floor(Math.random() * 255) +
      "," +
      1 / (Math.floor(Math.random() * 5) + 1) +
      ")"
  );
  pattern.style.setProperty(
    "--color2",
    "rgba(" +
      Math.floor(Math.random() * 255) +
      "," +
      Math.floor(Math.random() * 255) +
      "," +
      Math.floor(Math.random() * 255) +
      "," +
      1 / (Math.floor(Math.random() * 5) + 1) +
      ")"
  );
  colors.forEach(function (part, index) {
    this[index] =
      "rgba(" +
      Math.floor(Math.random() * 255) +
      "," +
      Math.floor(Math.random() * 255) +
      "," +
      Math.floor(Math.random() * 255) +
      "," +
      1 / (Math.floor(Math.random() * 5) + 1) +
      ")";
  }, colors);
  document.querySelectorAll(".cell").forEach((cell) => {
    for (let i = 0; i < colors.length; i++) {
      cell.style.setProperty("--color" + i, colors[i]);
    }
    cell.style.setProperty("--rotate", Math.floor(Math.random() * 360) + 1);
    cell.style.setProperty(
      "--rotate2",
      Math.floor(Math.random() * 360) + 1 + "deg"
    );
    cell.style.setProperty("--scale", Math.floor(Math.random() * 5) + 1);
    cell.style.setProperty("--scale2", Math.floor(Math.random() * 5) + 1);
    cell.style.setProperty("--distance", Math.floor(Math.random() * 25) + 10);
    cell.style.setProperty("--distance2", Math.floor(Math.random() * 25) + 10);
  });

  document.querySelectorAll(".cellsvg1").forEach((svg) => {
    svg.setAttribute("d", paths1[Math.floor(Math.random() * 3) + 0]);
  });

  document.querySelectorAll(".cellsvg2").forEach((svg) => {
    svg.setAttribute("d", paths2[Math.floor(Math.random() * 4) + 0]);
  });
  html2canvas(document.getElementById("pattern"), {
    useCORS: true
  }).then(function (canvas) {
    imageURL = canvas.toDataURL("image/jpg");
  });
}

document.addEventListener(
  "click",
  function (event) {
    document.body.classList.add("loading");
    drawShirt();
    setTimeout(() => {
      reset();
      document.body.classList.remove("loading");
    }, 1000);
  },
  false
);

window.addEventListener(
  "load",
  function (event) {
    drawShirt();
    setTimeout(() => {
      reset();
      document.body.classList.remove("loading");
    }, 5000);
  },
  false
);

              
            
!
999px

Console