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

              
                <input type="range" min="1" max="7" step="1" id="step" value="1">
<section>
  <p>Draw 100 evenly-spaced dots along a circle</p>
  <p>For every dot, use a noise algorithm to vary the radius</p>
  <p>Connect the dots and hide them</p>
  <p>Draw more shapes with the same logic while reducing the radius</p>
  <p>Fade the lines from the center to the outside</p>
  <p>Animate the shapes using the frame count in your noise function</p>
  <p>Go crazy</p>
</section>

              
            
!

CSS

              
                body {
  margin: 0;
  overflow: hidden;
  display: flex;
  height: 100vh;
  background: black;
}
canvas {
  margin: auto;
  touch-action: none;
}

@mixin track {
  box-sizing: border-box;
  height: 6px;
	background: #fff;
  -webkit-appearance: none;
  appearance: none;
}

@mixin thumb {
  box-sizing: border-box;
	width: 30px;
  height: 30px;
	border-radius: 50%;
	background: #fff;
  border: 2px solid black;
  -webkit-appearance: none;
  appearance: none;
  cursor: grab;
}

input {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: 80%;
  height: 34px;
  max-width: 400px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  &:active {
    cursor: grabbing;
  }
  &::-webkit-slider-runnable-track {@include track }
	&::-moz-range-track { @include track }
	&::-ms-track { @include track }
  
  &::-webkit-slider-thumb {margin-top: -12px;@include thumb}
	&::-moz-range-thumb { @include thumb }
  &::-ms-thumb {margin-top:0px;@include thumb}
}

section {
  box-sizing: border-box;
  font-size: 30px;
  color: white;
  position: fixed;
  left: 0;
  top: 20px;
  width: 100%;
  text-align: center;
  padding: 10px 10%;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 0 3px black, 0 0 4px black, 0 0 5px black;
  background: rgba(0, 0, 0, 0.7);
  font-family: 'Montserrat', sans-serif;
  p {
    margin: 0;
  }
  @media (max-width: 500px) {
    font-size: 24px;
  }
}

code {
  white-space: nowrap;
}
              
            
!

JS

              
                const _noise = noise;
_noise.seed(Math.random() * 100);
const anim = {t: 0};
let ctx;
console.clear();

/* ====== STEP 1 ====== */
function goToStep1 () {
  noLoop();
  fill(255);
}

function step1 () {
  clear();
  const r = min(width, height) * 0.35;
  for (let i = 0; i < 100; i++) {
    const x = cos(i / 100 * TWO_PI) * r + width / 2;
    const y = sin(i / 100 * TWO_PI) * r + height / 2;
    circle(x, y, 5);
  }
}

/* ====== STEP 2 ====== */
function goToStep2 () {
  loop();
  fill(255);
  noStroke();
  gsap.fromTo(anim, {
    t: 0 
  }, {
    t: 1,
    duration: 3,
    ease: 'power2.out'
  });
}

function step2 () {
  clear();
  const r = min(width, height) * 0.35;
  for (let i = 0; i < 100; i++) {
    let x = cos(i / 100 * TWO_PI);
    let y = sin(i / 100 * TWO_PI);
    const offset = _noise.simplex3(x, y, 0) * (r / 5) * anim.t;
    x *= r + offset;
    y *= r + offset;
    x += width / 2;
    y += height / 2;
    circle(x, y, 5);
  }
}

/* ====== STEP 3 ====== */
function goToStep3 () {
  loop();
  noFill();
  gsap.fromTo(anim, {
    t: 0 
  }, {
    t: 1,
    duration: 3,
    ease: 'none'
  });
}

function step3 () {
  clear();
  const r = min(width, height) * 0.35;
  beginShape();
  for (let i = 0; i <= 100; i++) {
    let x = cos(i / 100 * TWO_PI);
    let y = sin(i / 100 * TWO_PI);
    const offset = _noise.simplex3(x, y, 0) * (r / 5);
    x *= r + offset;
    y *= r + offset;
    x += width / 2;
    y += height / 2;
    if (anim.t >= (i/100)) {
      vertex(x, y);
    }
    fill(255);
    noStroke();
    circle(x, y, 5 * (1 - anim.t));
  }
  stroke(255);
  noFill();
  endShape();
}

/* ====== STEP 4 ====== */
function goToStep4 () {
  loop();
  stroke(255);
  fill(0);
  gsap.fromTo(anim, {
    t: 0 
  }, {
    t: 1,
    duration: 3,
    ease: 'none'
  });
}

function step4 () {
  clear();
  let r = min(width, height) * 0.35;
  const rings = 70;
  for (let j = 0; j <= (rings * anim.t); j++) {
    let rad = (r / rings) * (rings - j);
    beginShape();
    for (let i = 0; i <= 100; i++) {
      let x = cos(i / 100 * TWO_PI);
      let y = sin(i / 100 * TWO_PI);
      const offset = _noise.simplex3(x, y + (j * 0.03), 0) * (rad / 5);
      x *= rad + offset;
      y *= rad + offset;
      x += width / 2;
      y += height / 2;
      vertex(x, y);
    }
    endShape();
  }
}

/* ====== STEP 5 ====== */
function goToStep5 () {
  loop();
  stroke(255);
  noFill();
  gsap.fromTo(anim, {
    t: 0 
  }, {
    t: 1,
    duration: 3,
    ease: 'none'
  });
}

function step5 () {
  clear();
  let r = min(width, height) * 0.35;
  const rings = 70;
  for (let j = 0; j < rings; j++) {
    let rad = (r / rings) * (rings - j);
    beginShape();
    for (let i = 0; i <= 100; i++) {
      let x = cos(i / 100 * TWO_PI);
      let y = sin(i / 100 * TWO_PI);
      const offset = _noise.simplex3(x, y + (j * 0.03), 0) * (rad / 5);
      x *= rad + offset;
      y *= rad + offset;
      x += width / 2;
      y += height / 2;
      vertex(x, y);
    }
    stroke(j / rings * 175 + 80);
    endShape();
  }
}

/* ====== STEP 6 ====== */
let frames = 0;
function goToStep6 () {
  loop();
  ctx.fillStyle = 'black';
  frames = 0;
}

function step6 () {
  clear();
  let r = min(width, height) * 0.35;
  const rings = 70;
  for (let j = 0; j < rings; j++) {
    let rad = (r / rings) * (rings - j);
    beginShape();
    for (let i = 0; i <= 100; i++) {
      let x = cos(i / 100 * TWO_PI);
      let y = sin(i / 100 * TWO_PI);
      const offset = _noise.simplex3(x, y + (j * 0.03), frames * 0.003) * (rad / 5);
      x *= rad + offset;
      y *= rad + offset;
      x += width / 2;
      y += height / 2;
      vertex(x, y);
    }
    stroke(j / rings * 175 + 80);
    endShape();
  }
  frames++;
}

/* ====== STEP 7 ====== */
function goToStep7 () {
  loop();
}

function step7 () {
  clear();
  let r = min(width, height) * 0.35;
  const rings = 40;
  for (let j = 0; j < rings; j++) {
    let rad = (r / rings) * (rings - j);
    ctx.beginPath();
    for (let i = 0; i <= 150; i++) {
      let x = cos(i / 100 * TWO_PI);
      let y = sin(i / 100 * TWO_PI);
      const offset = _noise.simplex3(x, y + (j * 0.03), frames * 0.003) * (rad / 3);
      x *= rad + offset;
      y *= rad + offset;
      x += width / 2;
      y += height / 2;
      ctx.lineTo(x, y);
    }
    ctx.fillStyle = `hsl(${j/rings * 360}, 70%, 70%)`;
    ctx.strokeStyle = `hsl(${j/rings * 360}, 70%, 80%)`;
    ctx.fill();
    ctx.stroke();
  }
  frames++;
}

function setup () {
  const canvas = createCanvas(windowWidth, windowHeight);
  ctx = canvas.drawingContext;
  
  windowResized();
  document.querySelector('#step').addEventListener('input', () => {
    if (window['goToStep' + step.value]) {
      window['goToStep' + step.value]();
    }
    draw();
  });
}

function windowResized () {
  resizeCanvas(windowWidth, windowHeight);
  
  if (window['goToStep' + step.value]) {
    window['goToStep' + step.value]();
  }
  draw();
}

const texts = document.querySelectorAll('section p');
function draw () {
  window['step' + step.value]();
  
  texts.forEach(text => text.style.display = 'none');
  texts[step.value - 1].style.display = 'block';
}

              
            
!
999px

Console