Waves
How do I make an waves?
What is a waves? How do you make a waves? This script and codes were developed by Hakim El Hattab on 24 September 2022, Saturday.
Waves - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Waves</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas></canvas> <script src="js/index.js"></script>
</body>
</html>
Waves - Script Codes CSS Codes
html,
body { height: 100%; width: 100%;
}
body { display: -webkit-box; display: -ms-flexbox; display: flex; background-color: #fff;
}
canvas { margin: auto; width: 100%; height: 100%;
}
Waves - Script Codes JS Codes
'use strict';
var canvas = document.querySelector('canvas');
var context = canvas.getContext('2d');
var lines = [];
var colors = [['#4f3a4b', '#e55256'], ['#fff', '#111'], ['#e37169', '#26282a'], ['#eed87b', '#28292b'], ['#0d5b5c', '#e6e6e6'], ['#d4e8e1', '#e24c68'], ['#fbfc65', '#1666bd'], ['#f3c8ed', '#1790d0'], ['#111', '#fff']];
var colorIndex = -1;
var step = 0, width = 0, height = 0;
document.ontouchstart = color;
document.onmousedown = color;
window.onresize = setup;
setup();
color();
update();
function setup() { width = window.innerWidth, height = window.innerHeight; lines.length = 0; var lineCount = height / 26; var pointCount = 14; var spacingH = width / pointCount; var spacingV = height / lineCount; for (var v = 0; v < lineCount; v++) { var line = { points: [], ran: 0.2 + Math.random() * 0.7 }; for (var h = 0; h < pointCount; h++) { line.points.push({ nx: h * spacingH, ny: v * spacingV }); } line.points.push({ nx: width + spacingH, ny: v * spacingV }); lines.push(line); }
}
function color() { colorIndex = ++colorIndex % colors.length; canvas.style.backgroundColor = colors[colorIndex][0];
}
function update() { step += 0.8; canvas.width = width; canvas.height = height; context.clearRect(0, 0, width, height); context.lineWidth = 2; context.strokeStyle = colors[colorIndex][1]; context.fillStyle = colors[colorIndex][0]; lines.forEach(function (line, v) { context.beginPath(); line.points.forEach(function (point, h) { point.x = point.nx, point.y = point.ny + Math.sin((point.x * line.ran + (step + point.ny)) / 40) * (6 + point.ny / height * 34); }); line.points.forEach(function (point, h) { var nextPoint = line.points[h + 1]; if (h === 0) { context.moveTo(point.x, point.y); } else if (nextPoint) { var cpx = point.x + (nextPoint.x - point.x) / 2; var cpy = point.y + (nextPoint.y - point.y) / 2; context.quadraticCurveTo(point.x, point.y, cpx, cpy); } }); context.stroke(); context.lineTo(width, height); context.lineTo(0, height); context.closePath(); context.fill(); }); requestAnimationFrame(update);
}
Developer | Hakim El Hattab |
Username | hakimel |
Uploaded | September 24, 2022 |
Rating | 4.5 |
Size | 3,771 Kb |
Views | 20,240 |
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 |
Progress Nav | 6,925 Kb |
Spiral | 2,958 Kb |
Linjer | 4,882 Kb |
Kontext | 4,490 Kb |
CSS Spinner Animation | 5,951 Kb |
Cloudy Spiral CSS animation | 6,587 Kb |
Hypnos | 2,937 Kb |
Avgrund | 3,474 Kb |
Animated Line Chart | 3,305 Kb |
Ladda | 6,843 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 |
Twitch | SarahDunlap | 2,937 Kb |
Material design - button rainbow circle | Kunukn | 3,652 Kb |
A Pen by Huan Nghiem | Nightshade | 10,646 Kb |
Buttons for autumn | Nikazawila | 1,795 Kb |
Button fills | Zubfatal | 5,205 Kb |
Tail rose iris lined | Kbrtrm | 1,846 Kb |
Flip test | Madhes | 1,635 Kb |
Perspective Origin Demo | Agelber | 3,614 Kb |
React Recipe Box | Krokodill | 5,347 Kb |
Animated Vertical CSS3 Menu Black | MaCeLMp4 | 2,750 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!