Rift

Developer
Size
2,213 Kb
Views
42,504

How do I make an rift?

Inspired by this Pinterest pin . What is a rift? How do you make a rift? This script and codes were developed by Gabi on 22 August 2022, Monday.

Rift Previews

Rift - Script Codes HTML Codes

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

Rift - Script Codes CSS Codes

* { margin: 0; overflow: hidden; background-color: #000;
}

Rift - Script Codes JS Codes

var c = document.getElementById("c");
var ctx = c.getContext("2d");
var cw = c.width = window.innerWidth;
var ch = c.height = window.innerHeight;
var cx = cw / 2, cy = ch / 2;
var rad = Math.PI / 180;
var frames = 0;
var requestId = null;
ctx.lineWidth = 3;
ctx.strokeStyle = "white";
ctx.fillStyle = "rgba(0,0,0,1)";
var Amplitude = 50, amplitude;
var step = .5;
var W = 360 * step;
var I = 1 / step;
var offset;
function Draw() { frames += 3; ctx.clearRect(0, 0, cw, ch); for (var Y = -Amplitude; Y < ch + Amplitude; Y += 10) { offset = cx + 100 * Math.sin(Y * rad) - 100; amplitude = Amplitude * Math.sin((frames + Y) * rad); ctx.beginPath(); ctx.moveTo(0, Y + 3 * Amplitude); for (var x = 0; x < cw; x++) { if (x < offset || x > offset + (360 * step)) { y = Y; } else { y = amplitude * Math.cos(rad * (x - offset) * I) + Y - amplitude; } ctx.lineTo(x, y); } ctx.lineTo(cw, Y + 3 * Amplitude); ctx.closePath(); ctx.stroke(); ctx.fill(); } requestId = window.requestAnimationFrame(Draw);
}
function Init() { if (requestId) { window.cancelAnimationFrame(requestId); requestId = null; } cw = c.width = window.innerWidth; ch = c.height = window.innerHeight; cx = cw / 2, cy = ch / 2; frames = 0; Amplitude = 50, amplitude; step = .5; W = 360 * step; I = 1 / step; console.log(I) ctx.lineWidth = 3; ctx.strokeStyle = "white"; ctx.fillStyle = "rgba(0,0,0,1)"; requestId = window.requestAnimationFrame(Draw);
}
window.setTimeout(function() { Init(); window.addEventListener('resize', Init, false);
}, 15);
Rift - Script Codes
Rift - Script Codes
Home Page Home
Developer Gabi
Username enxaneta
Uploaded August 22, 2022
Rating 4.5
Size 2,213 Kb
Views 42,504
Do you need developer help for Rift?

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!

Gabi (enxaneta) Script Codes
Create amazing web content 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!