HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="bg"></div>
<div class="loader p-text p-flex-hzt-center" id="canvas-loader">
<p> <span class="loader__i">🦖</span><br/><span class="loader__txt">Loading</span></p>
</div>
<div id="canvas-wrapper" aria-label="grunge poster"></div>
<!-- Shaders taken from Mario Carrillo's Tut: https://tympanus.net/codrops/2020/03/17/create-a-wave-motion-effect-on-an-image-with-three-js/ -->
<script type="x-shader/x-fragment" id="fragment">
precision mediump float;
varying vec2 vUv;
varying float vWave;
uniform sampler2D uTexture;
void main() {
// I edited this part a bit to get me those grunge colors and a different wave effect <3
float wave = vWave * 0.50;
float r = texture2D(uTexture, vUv + wave).r;
float g = texture2D(uTexture, vUv).g;
float b = texture2D(uTexture, vUv + wave).b;
vec3 texture = vec3(r, g, b);
gl_FragColor = vec4(texture, 1.0);
}
</script>
<script type="x-shader/x-vertex" id="vertex">
precision highp float;
varying vec2 vUv;
varying float vWave;
uniform float uTime;
// Description : Array and textureless GLSL 2D/3D/4D simplex
// noise functions.
// Author : Ian McEwan, Ashima Arts.
// Maintainer : ijm
// Lastmod : 20110822 (ijm)
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
// Distributed under the MIT License. See LICENSE file.
// https://github.com/ashima/webgl-noise
vec3 mod289(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
return mod289(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r) {
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise(vec3 v) {
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
// First corner
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
// Other corners
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
vec3 x1 = x0 - i1 + C.xxx;
vec3 x2 = x0 - i2 + C.yyy;
vec3 x3 = x0 - D.yyy;
// Permutations
i = mod289(i);
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
// Gradients: 7x7 points over a square, mapped onto an octahedron.
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
float n_ = 0.142857142857;
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ );
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
// Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
p3 *= norm.w;
// Mix final noise value
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
dot(p2,x2), dot(p3,x3) ) );
}
void main() {
vUv = uv;
vec3 pos = position;
// I edited this part a bit to get me a slightly different noise frequency and amplitude
float noiseFreq = 1.5;
float noiseAmp = 0.15;
vec3 noisePos = vec3(pos.x * noiseFreq + uTime, pos.y, pos.z);
pos.z += snoise(noisePos) * noiseAmp;
vWave = pos.z;
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
}
</script>
$c1: hotpink;
$c2: #fffffd; // white
$c3: #191919; // black
* {
user-select: none;
}
.p-text {
color: $c2;
font-family: Helvetica, Arial, sans-serif;
line-height: 1.5;
text-align: center;
text-transform: lowercase;
}
.p-flex-hzt-center {
display: flex;
justify-content: center;
}
body {
height: 100vh;
background-color: $c1;
margin: 0;
padding: 0;
overflow: hidden;
}
.bg {
width: 100%;
height: 100%;
/*Free Sprinkles SVG background provided by SVGeez.com - CC 4.0 License - © 2019 Megan Young */
fill: rgb(124, 77, 225);
background-size: 131px 131px;
background-repeat: repeat;
background-image: url("data:image/svg+xml,%3Csvg id='Layer_1' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 500 500' fill-opacity='1' %3E%3Cstyle%3E .st0{fill:rgb(124, 77, 225)} %3C/style%3E%3Cpath class='st0' d='M55.5 475h-19c-1.9 0-3.5-1.6-3.5-3.5s1.6-3.5 3.5-3.5h19c1.9 0 3.5 1.6 3.5 3.5s-1.6 3.5-3.5 3.5zM144.7 178.9c-.4 0-.8-.1-1.2-.2-1.8-.7-2.7-2.7-2.1-4.5l6.6-17.8c.7-1.8 2.7-2.7 4.5-2.1 1.8.7 2.7 2.7 2.1 4.5l-6.6 17.8c-.6 1.4-1.9 2.3-3.3 2.3zM107.9 130.4c-1 0-2.1-.5-2.7-1.3l-11.8-14.9c-1.2-1.5-.9-3.7.6-4.9 1.5-1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.2.3-5.6 1.7-1.5 4.2-1.3 5.6.3l8 9c1.5 1.7 1.3 4.2-.3 5.6-.7.7-1.7 1-2.6 1zM261 80c-2.1 0-3.9-1.7-4-3.8l-1-23c-.1-2.2 1.6-4.1 3.8-4.2 2.2-.1 4.1 1.6 4.2 3.8l1 23c.1 2.2-1.6 4.1-3.8 4.2h-.2zM209 39c-.5 0-1.1-.1-1.6-.3-2-.9-3-3.2-2.1-5.3l6-14c.9-2 3.2-3 5.3-2.1 2 .9 3 3.2 2.1 5.3l-6 14c-.7 1.5-2.2 2.4-3.7 2.4zM460 327c-.8 0-1.7-.3-2.4-.8-1.8-1.3-2.1-3.8-.8-5.6l12-16c1.3-1.8 3.8-2.1 5.6-.8 1.8 1.3 2.1 3.8.8 5.6l-12 16c-.8 1-2 1.6-3.2 1.6zM446 182c-1.6 0-3.1-1-3.7-2.6l-3-8c-.8-2.1.3-4.4 2.3-5.1 2.1-.8 4.4.3 5.1 2.3l3 8c.8 2.1-.3 4.4-2.3 5.1-.5.2-.9.3-1.4.3zM466 213c-.9 0-1.7-.3-2.5-.8-1.7-1.4-2.1-3.9-.7-5.6l7-9c1.4-1.7 3.9-2.1 5.6-.7 1.7 1.4 2.1 3.9.7 5.6l-7 9c-.7 1-1.9 1.5-3.1 1.5zM9 391c-1.3 0-2.6-.6-3.3-1.8-1.2-1.8-.7-4.3 1.1-5.5l12-8c1.8-1.2 4.3-.7 5.5 1.1 1.2 1.8.7 4.3-1.1 5.5l-12 8c-.7.5-1.4.7-2.2.7z'/%3E%3C/svg%3E");
position: absolute;
top: 0;
left: 0;
z-index: -10;
}
.loader {
width: 100%;
height: 100%;
font-size: 0.6rem;
letter-spacing: 3px;
position: absolute;
top: 0;
left: 0;
z-index: 120;
align-items: center;
&__i {
font-size: 1.8rem;
}
&__txt {
background-color: $c3;
padding: 5px 6px 5px 9px;
}
}
/*
* GRUNGE POSTER
* Made with ThreeJS - Enjoy!
*
* Only the poster wave motion effect is a remix from original code by Mario Carrillo's Tut: https://tympanus.net/codrops/2020/03/17/create-a-wave-motion-effect-on-an-image-with-three-js/
*
* Use cursor to rotate the poster in space.
* On mobile touch + drag screen.
*
* Have any performance tips on this code? I'm all ears!
*
* Photo asset taken from the Internet. No idea who was the photographer.
*
* #045 - #100DaysOfCode
* By ilithya | 2020
* https://www.ilithya.rocks/
* https://twitter.com/ilithya_rocks
*/
// CREATE LOADER
let loadingManager = null;
let ASSETS_LOADED = false;
const loadingScreen = {
scene: new THREE.Scene(),
camera: new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
100
),
removeText() {
const loadingText = document.querySelector("#canvas-loader");
if (loadingText.parentNode) loadingText.parentNode.removeChild(loadingText);
}
};
// CREATE POSTER
const nearDist = 0.1;
const farDist = 100;
const camera = new THREE.PerspectiveCamera(
45,
window.innerWidth / window.innerHeight,
nearDist,
farDist
);
const scene = new THREE.Scene();
const renderer = new THREE.WebGLRenderer({
alpha: true,
antialias: true,
});
const clock = new THREE.Clock();
const canvasWrapper = document.querySelector("#canvas-wrapper");
const init = () => {
// Initialize loader
loadingManager = new THREE.LoadingManager();
loadingManager.onLoad = () => {
loadingScreen.removeText();
ASSETS_LOADED = true;
};
// Initialize rendered world
camera.position.set(0, 0, 1);
renderer.setClearColor("hotpink", 0);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
canvasWrapper.appendChild(renderer.domElement);
};
init();
// CREATE POSTER
// Based on Mario Carrillos's Wave Motion Effect code, March 2020
const posterGeom = new THREE.PlaneGeometry(0.56, 0.36, 60, 60);
const textureLoader = new THREE.TextureLoader(loadingManager);
const texture = textureLoader.load(
"https://s3-us-west-2.amazonaws.com/s.cdpn.io/249663/m560x360.jpg"
);
const vertexShader = document.querySelector("#vertex").textContent;
const fragmentShader = document.querySelector("#fragment").textContent;
const posterMat = new THREE.ShaderMaterial({
uniforms: {
// These properties play together with the custom shaders
uTime: { value: 0.0 },
uTexture: { value: texture }
},
vertexShader,
fragmentShader,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(posterGeom, posterMat);
scene.add(mesh);
// CREATE 3D CONFETTI
const Deco = function (group) {
this.group = group;
const radius = 0.02;
this.triangleGeom = new THREE.TetrahedronBufferGeometry(radius);
this.triangleMat = new THREE.MeshNormalMaterial();
};
Deco.prototype.create = function () {
const count = Math.round(Math.max(window.innerWidth, window.innerHeight) / 18);
for (let i = 0; i < count; i++) {
const deco = new THREE.Mesh(this.triangleGeom, this.triangleMat);
const tau = 2 * Math.PI;
const d = nearDist * 8;
const d2 = d * 2;
deco.position.x = Math.random() * d2 - d;
deco.position.y = Math.random() * d2 - d;
deco.rotation.x = Math.random() * tau;
deco.rotation.y = Math.random() * tau;
deco.matrixAutoUpdate = false;
deco.updateMatrix();
this.group.add(deco);
}
};
const group = new THREE.Group();
const confetti = new Deco(group);
confetti.create();
scene.add(group);
// CREATE MOUSE OVER/TOUCH EFFECT
let mouseX = 0;
let mouseY = 0;
const mouseFX = {
movePoster(cX, cY) {
mouseX = (cX / window.innerWidth) * 2 - 1;
mouseY = -(cY / window.innerHeight) * 2 + 1;
mesh.rotation.x = mouseY * 3;
mesh.rotation.y = mouseX * 3;
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
},
onMouseMove(e) {
mouseFX.movePoster(e.clientX, e.clientY);
},
onTouchMove(e) {
const touchX = e.changedTouches[0].clientX;
const touchY = e.changedTouches[0].clientY;
mouseFX.movePoster(touchX, touchY);
}
};
document.addEventListener("mousemove", mouseFX.onMouseMove);
document.addEventListener("touchmove", mouseFX.onTouchMove);
// RESIZE CANVAS
const onWindowResize = () => {
const w = window.innerWidth;
const h = window.innerHeight;
camera.aspect = w / h;
camera.updateProjectionMatrix();
renderer.setSize(w, h);
};
window.addEventListener("resize", onWindowResize);
// CREATE ANIMATIONS
group.position.y = 1.3;
const addConfettiAnim = () => {
const c = 0.003;
let speed = c + Math.random() * c;
group.position.y -= speed;
if (group.position.y < -1.165) {
group.position.y = 1.3;
group.rotation.x = 2 * Math.PI;
speed = 0;
}
};
const addPosterAnim = () => {
// By Mario Carrillo, March 2020
posterMat.uniforms.uTime.value = clock.getElapsedTime();
};
// RENDER 3D GRAPHIC
const render = () => {
if (!ASSETS_LOADED) {
renderer.render(loadingScreen.scene, loadingScreen.camera);
requestAnimationFrame(render);
return;
}
addConfettiAnim();
addPosterAnim();
renderer.render(scene, camera);
requestAnimationFrame(render);
};
render();
Also see: Tab Triggers