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="actions">
    <input type="range" class="wave-speed" min="0" max="0.5" step="0.0005" value="0.05">
    <input type="range" class="wave-x" min="0" max="50" step="0.0005" value="10">
    <input type="range" class="wave-y" min="0" max="50" step="0.0005" value="5">
    <input type="text" class="line1" value="Wobbly">
    <input type="text" class="line2" value="Mirrors">
  </div>


<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk" rel="stylesheet">

              
            
!

CSS

              
                body {
  background-color: #FFCA32;
  /* color: #ff0000; */
}
canvas {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
div.actions {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1;

  display: flex;
  align-items: center;
}

input {
  width: 100px;
  margin-left: 5px;
}
              
            
!

JS

              
                let font
let graphic

const waveInput = document.querySelector("input.wave-speed")
const waveX = document.querySelector("input.wave-x")
const waveY = document.querySelector("input.wave-y")
const line1Input = document.querySelector("input.line1")
const line2Input = document.querySelector("input.line2")


// function preload() {
//   font = loadFont();
//   push(); // text just drawn once
  // textFont("Maven Pro");
// }

function setup(params) {
  createCanvas(1200, 600)

  createCopy()
}

function draw() {
  background("#FFCA32")

  const tileSize = 10

  for(let x = 0; x < 120; x++) {
    for(let y = 0; y < 60; y++) {

      const waveSpeed = waveInput.value

      const distortionX = sin(frameCount * waveSpeed + x * 0.5 + y * 0.1) * waveX.value
      const distortionY = sin(frameCount * waveSpeed + x * 0.5 + y * 1) * waveY.value

      // source
      const sx = x * tileSize + distortionX
      const sy = y * tileSize + distortionY
      const sw = tileSize
      const sh = tileSize

      // destination
      const dx = x * tileSize
      const dy = y * tileSize
      const dw = tileSize
      const dh = tileSize

      image(graphic, dx, dy, dw, dh, sx, sy, sw, sh)
    }
  }
}

function createCopy() {
  graphic = createGraphics(1000, 500)

  const text = line1Input.value + "\n" + line2Input.value

  graphic.fill("#0007C2")
  graphic.textSize(200)
  graphic.textAlign(CENTER, CENTER)
  push(); // text just drawn once
  graphic.textFont('Space Grotesk')
  graphic.textLeading(150)
  graphic.text(text, width/2, height/2)
}

line1Input.addEventListener('input', ()=>createCopy())
line2Input.addEventListener('input', ()=>createCopy())
              
            
!
999px

Console