JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.

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.

+ add another resource

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

` ````
<!--
A basic experiment with moving particles!
Made with Phenomenon: A fast 2kB low-level WebGL API! ✨
https://github.com/vaneenige/phenomenon
-->
<canvas />
```

` ````
html,
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
canvas {
position: fixed;
width: 100%;
height: 100%;
image-rendering: pixelated;
}
```

` ````
const multiplier = 40000;
const begin = 0.4;
const duration = 0.6;
function h2r(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1 / 6) return p + (q - p) * 6 * t;
if (t < 1 / 2) return q;
if (t < 2 / 3) return p + (q - p) * 6 * (2 / 3 - t);
return p;
};
function getHSL(h, s, l){
h = (h % 1 + 1) % 1;
s = Math.max(0, Math.min(1, s));
l = Math.max(0, Math.min(1, l));
if (s === 0) return [l, l, l];
const p = l <= 0.5 ? l * (1 + s) : l + s - l * s;
const q = 2 * l - p;
return [h2r(q, p, h + 1 / 3), h2r(q, p, h), h2r(q, p, h - 1 / 3)];
};
function getRandom(value) {
const floor = -value;
return floor + Math.random() * value * 2;
}
const attributes = [
{
name: "aPositionStart",
data: (index, total) => {
return [
0,
-1,
0,
];
},
size: 3
},
{
name: "aControlPointOne",
data: (index, total) => {
const angle = index * (2 * Math.PI / total);
return [
Math.cos(angle) * 1.5 + getRandom(0.5),
1.5 + getRandom(0.5),
Math.sin(angle) * 1.5,
];
},
size: 3
},
{
name: "aControlPointTwo",
data: (index, total) => {
const angle = index * (2 * Math.PI / total);
return [
Math.cos(angle) + getRandom(1),
1 + getRandom(0.5),
Math.sin(angle) + getRandom(1)
];
},
size: 3
},
{
name: "aPositionEnd",
data: (index, total) => {
const angle = index * (2 * Math.PI / total);
return [
Math.cos(angle) + getRandom(2),
-2,
0,
];
},
size: 3
},
{
name: "aColor",
data: (index, total) =>
getHSL(
begin + index / total * 0.2,
0.6 + getRandom(0.1),
0.6 + getRandom(0.1),
),
size: 3
},
{
name: "aOffset",
data: i => [i * ((1 - duration) / (multiplier - 1))],
size: 1
}
];
const uniforms = {
uProgress: {
type: "float",
value: 0.0
}
};
const vertex = `
attribute vec3 aPositionStart;
attribute vec3 aControlPointOne;
attribute vec3 aControlPointTwo;
attribute vec3 aPositionEnd;
attribute vec3 aPosition;
attribute vec3 aColor;
attribute float aOffset;
uniform float uProgress;
uniform mat4 uProjectionMatrix;
uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
varying vec3 vColor;
vec3 bezier4(vec3 a, vec3 b, vec3 c, vec3 d, float t) {
return mix(mix(mix(a, b, t), mix(b, c, t), t), mix(mix(b, c, t), mix(c, d, t), t), t);
}
void main(){
float tProgress = min(1.0, max(0.0, (uProgress - aOffset)) / ${duration});
vec3 newPosition = bezier4(aPositionStart, aControlPointOne, aControlPointTwo, aPositionEnd, tProgress);
gl_PointSize = 4.0;
gl_Position = uProjectionMatrix * uModelMatrix * uViewMatrix * vec4(newPosition + aPosition, 1.0);
vColor = aColor;
}
`;
const fragment = `
precision mediump float;
varying vec3 vColor;
void main(){
gl_FragColor = vec4(vColor, 1.0);
}
`;
const renderer = new Phenomenon({
canvas: document.querySelector("canvas"),
settings: {
clearColor: [239 / 255, 239 / 255, 239 / 255, 1],
position: {x: 0, y: 0, z: 1.2 },
shouldRender: true
}
});
renderer.add("starling", {
attributes,
multiplier,
uniforms,
vertex,
fragment,
onRender: instance => {
instance.uniforms.uProgress.value += 0.004;
if (instance.uniforms.uProgress.value >= 1.2) {
instance.uniforms.uProgress.value = 0;
}
}
});
```

999px

Shift F
Opt F
Find & Replace

Also see: Tab Triggers