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.

+ add another resource

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.

` ````
<canvas width="300" height="300" style="width:100%;height:100vh;" id="c"></canvas>
```

` ````
html,body{
border: 0;
padding: 0;
margin: 0;
overflow: hidden;
background: #000;
}
.info{
z-index:999;
position : absolute;
left:0;
top:0;
padding:10px;
color:#fff;
background: rgba(0,0,0,0.5);
text-transform:capitalize;
}
```

` ````
const canvas = document.getElementById('c');
const ctx = canvas.getContext("2d");
let height,width,innerpoints = [], outerpoints = [],particles = [];
const noofpoints = 200, trashold = 10;
let x, y, p, n, point,dx,dy,color
deltaangle = Math.PI * 2 / noofpoints,
r = Math.min(height,width) * 0.5;
const distance = (x1,y1,x2,y2) => {
return Math.sqrt(Math.pow(y2 - y1,2) + Math.pow(x2 - x1,2) )
}
const mapVal = (num, in_min, in_max, out_min, out_max) => {
return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
const resize = () => {
height = ctx.canvas.clientHeight;
width = ctx.canvas.clientWidth;
if(ctx.canvas.clientWidth !== canvas.width ||
ctx.canvas.clientHeight !== canvas.height
){
console.log("resized");
canvas.width = width
canvas.height = height
ctx.translate(canvas.width/2, canvas.height/2);
ctx.rotate(-Math.PI)
innerpoints = [];
r = 10;
for(let i = deltaangle; i <= Math.PI * 2 ; i += deltaangle){
x = r * 16 * Math.pow(Math.sin(i),3);
y = r * (13 * Math.cos(i) - 5 * Math.cos(2*i) - 2 *Math.cos(3*i) - Math.cos(4 * i));
innerpoints.push({
x,
y
})
x = 10 * r * 16 * Math.pow(Math.sin(i),3);
y = 10 * r * (13 * Math.cos(i) - 5 * Math.cos(2*i) - 2 *Math.cos(3*i) - Math.cos(4 * i));
outerpoints.push({
x,
y
})
let step = random(0.001,0.003,true);
particles.push({
step,
x,
y
})
}
}
}
const random = (min,max, isFloat) => {
if(isFloat) {
return (Math.random() * (max - min) + min);
}
return ~~(Math.random() * (max - min) + min);
}
resize();
//particles = [...outerpoints];
ctx.globalAlpha = 0.5;
ctx.globalCompositeOperation = 'source-over'
const draw = ()=>{
ctx.fillStyle = "rgba(0,0,0,0.03)"
ctx.fillRect(-width,-height,width*2,height*2);
ctx.beginPath();
for(let i = 0; i < innerpoints.length; i++){
s = outerpoints[i];
d = innerpoints[i];
point = particles[i]
if(distance(point.x, point.y,d.x,d.y) > 10) {
dx = d.x - s.x;
dy = d.y - s.y;
point.x += dx * point.step
point.y += dy * point.step
color = distance(0,0,point.x,point.y)
ctx.beginPath();
ctx.fillStyle = `hsl(${color % 360},100%,50%)`;
ctx.arc(point.x, point.y, 2, 0, Math.PI*2 ,false);
ctx.closePath();
ctx.fill();
} else {
point.x = d.x
point.y = d.y
ctx.beginPath();
ctx.arc(point.x, point.y, 2, 0, Math.PI*2 ,false);
ctx.closePath();
ctx.fill();
particles[i].x = s.x
particles[i].y = s.y
particles[i].step = random(0.001,0.003,true);
}
}
}
const render = () => {
resize();
draw();
requestAnimationFrame(render);
}
requestAnimationFrame(render);
```

999px

Shift F
Opt F
Find & Replace

Also see: Tab Triggers