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

              
                <h1>Thru.</h1>
              
            
!

CSS

              
                html, body { height: 100%; margin: 0; }
body {
  background: black;
  display: flex;
  justify-content: center;
  align-items: center;
}
h1 {
  color: white;
  font-size: 20vw;
  font-weight: 900;
}
              
            
!

JS

              
                // Built with VFX-JS
// https://amagi.dev/vfx-js
import { VFX } from "https://esm.sh/@vfx-js/core";

const shader = `
precision highp float;
uniform vec2 resolution;
uniform vec2 offset;
uniform vec2 mouse;
uniform float time;
uniform sampler2D src;

#define PI 3.141593
#define SAMPLES 64.

float hash(vec2 p) {
  return fract(sin(dot(p, vec2(489., 589.))) * 492.) * 2. - 1.;
}
float hash(vec3 p) {
  return fract(sin(dot(p, vec3(489., 589., 58.))) * 492.) * 2. - 1.;
}
vec2 hash2(vec3 p) {
  return vec2(hash(p), hash(p + 1.));
}
vec4 readTex(vec2 uv) {
  if (uv.x < 0. || uv.x > 1. || uv.y < 0. || uv.y > 1.) { return vec4(0); }
  return texture2D(src, uv);
}
vec3 spectrum(float x) {
    return cos((x - vec3(0, .5, 1)) * vec3(.6, 1., .5) * PI);
}

void main() {
  vec2 uv = (gl_FragCoord.xy - offset) / resolution;  
  if (readTex(uv).r > 0.) { discard; }
  
  vec2 p = uv * 2. - 1.;
  p.x *= resolution.x / resolution.y;
  
  // Determine light position
  vec2 mp = (mouse - offset) / resolution;
  mp = mp * 2. - 1.;
  mp.x *= resolution.x / resolution.y;
  
  vec2 rp = p;
  vec2 d = (mp - p) / SAMPLES;
  float acc = 0.;
  
  for (float i = 0.; i < SAMPLES; i++) {
    rp += d;
    rp += hash2(vec3(rp, i)) * 0.5 / SAMPLES;
    
    vec2 uv2 = rp;
    uv2.x /= resolution.x / resolution.y;
    uv2 = uv2 * 0.5 + 0.5;    
    acc += readTex(uv2).r / SAMPLES;
  }

  // Light
  float lm = length(p - mp);
  vec4 c = vec4(smoothstep(0., 1., pow(.1 / lm, .2)));
  
  c -= acc; // shadow
  c += vec4((spectrum(cos(acc * 3.5))), 1) * acc * 2.5; // rainbow
  
  c -= hash(vec3(uv.xyy)) * 0.01; // dither   
  gl_FragColor = c;  
}
`;

const vfx = new VFX();
vfx.add(document.querySelector('h1'), { shader, overflow: true, overlay: true });

              
            
!
999px

Console