Electric worm
How do I make an electric worm?
Random math stuff using waves and more waves. Feel free to use as you wish. Doubts? just message/post me. :). What is a electric worm? How do you make a electric worm? This script and codes were developed by Jeff Ibacache on 23 June 2022, Thursday.
Electric worm - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Electric worm</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>
Electric worm - Script Codes CSS Codes
body { margin: 0; padding: 0; background: #FFF;
}; canvas { position: absolute; width: 100%; height: 100%;
}
Electric worm - Script Codes JS Codes
var canvas;
var context;
var screenWidth;
var screenHeight;
var doublePI = Math.PI * 2;
var step = 30;
var offset = 0;
window.onload = function()
{ canvas = document.getElementById('canvas'); context = canvas.getContext('2d'); window.onresize = function() { screenWidth = window.innerWidth; screenHeight = window.innerHeight; canvas.width = screenWidth; canvas.height = screenHeight; }; window.onresize(); loop();
};
window.getAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback)
{ window.setTimeout(callback, 16.6);
};
function loop()
{ context.fillStyle = '#282828'; context.fillRect(0, 0, screenWidth, screenHeight); render(); step += 0.1; offset += Math.sin(step * 0.01) * 0.04; getAnimationFrame(loop);
}
function render()
{ if(Math.random() > 0.05) drawWave(180, 160, 15, false, 0); if(Math.random() > 0.8) drawWave(180, 160, 1, false, 8);
}
function drawWave(sw, sh, lineWidth, fill, randomFactor)
{ var i = 22; var length = 64; context.beginPath(); context.lineWidth = lineWidth; context.strokeStyle = '#FFF'; context.fillStyle = '#FFF'; context.lineJoin = "round"; context.lineCap = "round"; for(i; i <= length; ++i) { var norm = (i / length); var angle = doublePI * norm; var wave = norm * (Math.cos(step * 0.1) * 48 + 64); var x = Math.cos(angle + (Math.PI / 2) + offset) * (Math.cos(step * 0.6) * 20 + sw) + Math.cos(wave + step + offset) * (Math.sin(step + offset) * 8) + Math.cos(wave * 0.5 + step + offset) * 12 + (1 - (Math.random() * 2) * randomFactor); var y = Math.sin(angle + (Math.PI / 2) + offset) * (Math.sin(step) * 20 + sh) + Math.sin(wave + step + offset) * (Math.cos(step + offset) * 8) + Math.sin(wave * 0.5 + step + offset) * 16 + (1 - (Math.random() * 2) * randomFactor); if(i === 0) context.moveTo(x + (screenWidth >> 1), y + (screenHeight >> 1)); else context.lineTo(x + (screenWidth >> 1), y + (screenHeight >> 1)); if(!fill) context.stroke(); else context.fill(); } context.closePath();
}
Developer | Jeff Ibacache |
Username | jeffibacache |
Uploaded | June 23, 2022 |
Rating | 4 |
Size | 2,377 Kb |
Views | 38,456 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Wave | 1,997 Kb |
A Pen by Jeff Ibacache | 2,359 Kb |
Stardust | 2,629 Kb |
Wave Physics Playground | 3,267 Kb |
Bezier Fun | 3,319 Kb |
Pseudo 3D Particles | 2,548 Kb |
Playable Canvas Asteroids | 5,711 Kb |
Fake 3D Blob | 2,823 Kb |
Astral Spiral Playground | 2,764 Kb |
Pseudo Fluids | 3,266 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Animated Logo | Shakdaniel | 2,672 Kb |
See Through | Larrygeams | 77,410 Kb |
Very Simple Slider | Doodlemarks | 2,682 Kb |
SlideupBoxes | Gavra | 23,772 Kb |
AngularJS Datalist Directive | M-e-conroy | 2,366 Kb |
Starfield using KineticJS | Asp | 3,512 Kb |
After America | Jonathangarner | 2,686 Kb |
Buttons with style | Chbymnky | 2,082 Kb |
Sample Profile Screen | OurDailyBread | 5,375 Kb |
To Do List with Delete | Mattlbrody | 2,068 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!