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

              
                <!DOCTYPE html>
<html>

<head>
    <title>Displace / cut</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>

<body>

</body>

</html>
              
            
!

CSS

              
                html,
body {
    padding: 0;
    margin: 0;
    height: 100%;
    width: 100%;
}
body {
    overscroll-behavior: contain;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;

    background: rgb(0, 0, 0);
    background: linear-gradient(
        335deg,
        rgb(47, 47, 47) 0%,
        rgba(0, 0, 0, 1) 100%
    );
}
canvas {
    padding: 0;
    margin: auto;
    display: block;
    position: absolute;
    object-fit: contain;
    object-position: center;
    top: 0;
    left: 0;
    width: 1080px;
    height: 1080px;
    max-width: 100vw;
    max-height: 100vh;
}

              
            
!

JS

              
                
let gpos = [];
let gestureIdx = 0;
function setup() {
    createCanvas(1080, 1080);
    background(0);

    // Create gradient rect
    colorRect(0, 0, width, height);

    // Shadow
    setShadow((x = 3), (y = 3), (b = 15), (a = 200));
    
    // Gesture
    gpos = gesture();

}

function draw() {
	let pos = gpos[gestureIdx % gpos.length];
	for (let i = 0; i < gpos.length; i++) {
		if (pos !== gpos[i]) {
			let d = dist(pos[0], pos[1], gpos[i][0], gpos[i][1]);
			if (d > 25 && d < 90) {
				stroke(0);
				let fi = drawingContext.createLinearGradient(
					pos[0],
					pos[1],
					gpos[i][0],
					gpos[i][1],
				);
				fi.addColorStop(0, color(0, 0));
				fi.addColorStop(1, color(0, 255));
				drawingContext.strokeStyle = fi;
				line(pos[0], pos[1], gpos[i][0], gpos[i][1]);
			}
		}
	}
	circle(pos[0], pos[1], random(2, 5));
	gestureIdx++;
	if(gestureIdx >  gpos.length){
		noLoop();
	}
}

function gesture(){
    // Gesture ----------------------------
    let gPos = [];
	let noff = 0;
	let ns = 0.001;
	let gdir = createVector(0, 0);
	let gvel = createVector(0, 0);
	let vpos = createVector(width / 2, height / 2);
	let eachG = 0;
	for (let x = 0; x < width; x += 60) {
		for (let y = 0; y < height; y += 60) {
			let n = noise(x * ns, y * ns, noff);
			let dil = 20;
			gdir.x = cos(n * TAU * dil) * 10;
			gdir.y = sin(n * TAU * dil) * 10;
			gvel.add(gdir);
			gvel.mult(0.96);
			vpos.add(gvel);
			noff += 1;
			if (vpos.x < 0 || vpos.x > width || vpos.y < 0 || vpos.y > height) {
				vpos.set(random(width), random(height));
			}
			if (eachG % 2 == 0) {
				gPos.push([vpos.x, vpos.y]);
			}
			eachG++;
		}
	}
    return gPos;
}

// Create a rect with gradient color
function colorRect(x, y, w, h) {
    push();
    colorMode(HSB, 255, 255, 255, 255);
    rectMode(CENTER);
    fill(0);
    noStroke();
    let bg = drawingContext.createLinearGradient(x, y, w, h);
    bg.addColorStop(0, color(0));
    bg.addColorStop(1, color(255));
    drawingContext.fillStyle = bg;
    rect(width / 2, height / 2, w, h);
    pop();
}

// Shadow
function setShadow(x = 3, y = 3, b = 15, a = 200) {
    drawingContext.shadowOffsetX = x;
    drawingContext.shadowOffsetY = y;
    drawingContext.shadowBlur = b;
    drawingContext.shadowColor = color(0, a);
}
              
            
!
999px

Console