Wave

Developer
Size
1,997 Kb
Views
133,584

How do I make an wave?

Simple wave using canvas and mathemagics.. What is a wave? How do you make a wave? This script and codes were developed by Jeff Ibacache on 12 June 2022, Sunday.

Wave Previews

Wave - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Wave</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>

Wave - Script Codes CSS Codes

* {	margin: 0px;
}
canvas {	display: block;
}

Wave - Script Codes JS Codes

var canvas;
var context;
var width;
var height;
var offset = 0;
var acc = 0;
var PI2 = Math.PI * 2;
var lineDisplacement = 30;
window.onload = function()
{	canvas = document.getElementById('canvas'); canvas.style.width = window.innerWidth + "px"; setTimeout(function() { canvas.style.height = window.innerHeight + "px";
}, 0);	context = canvas.getContext('2d');	width = canvas.width = window.innerWidth;	height = canvas.height = window.innerHeight;	loop();
};
function loop()
{	drawSineWave();	requestAnimationFrame(loop);
}
function drawSineWave()
{	var i = 0;	var length = PI2; context.fillStyle = "#F3F0D1"; context.fillRect(0, 0, width, height);	context.strokeStyle = '#A9BD79';	context.beginPath();	context.moveTo(0, Math.sin(i + offset) * Math.cos(acc) + (height >> 1));	for(i; i < length; i += 0.2)	{	context.lineWidth = Math.sin(acc) * 40 + 60;	context.lineTo((i / PI2) * width, Math.sin(i + offset) * lineDisplacement + (height >> 1));	context.stroke();	}	offset += Math.cos(acc) * 0.08 + 0.14;	acc += 0.01;
}
Wave - Script Codes
Wave - Script Codes
Home Page Home
Developer Jeff Ibacache
Username jeffibacache
Uploaded June 12, 2022
Rating 3.5
Size 1,997 Kb
Views 133,584
Do you need developer help for Wave?

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!

Jeff Ibacache (jeffibacache) Script Codes
Create amazing sales emails with AI!

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!