Time Dilation
How do I make an time dilation?
Pushing the limits of time and space (and CSS). What is a time dilation? How do you make a time dilation? This script and codes were developed by Josh Beckwith on 29 August 2022, Monday.
Time Dilation - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Time Dilation</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>
<div class="layers"></div>
<div class="controls"> <div class="control"> <input id="layers" type="range" value="70" min="1" max="100"/> <label for="layers">layers</label> <div class="val"></div> </div> <div class="control"> <input id="offset-x" type="range" value="0" min="-400" max="400"/> <label for="offset-x">offset x</label> <div class="val"></div> </div> <div class="control"> <input id="offset-y" type="range" value="0" min="-400" max="400"/> <label for="offset-y">offset y</label> <div class="val"></div> </div> <div class="control"> <input id="dilation" type="range" value="-500" min="-640" max="2000"/> <label for="dilation">dilation</label> <div class="val"></div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>
Time Dilation - Script Codes CSS Codes
.layers { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); width: 500px; height: 500px;
}
.layer { position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background-image: url("https://farm2.staticflickr.com/1142/5135054840_3c31e76d7b_z_d.jpg"); border-radius: 50%; /* border: 1px solid red;*/
}
.controls { position: absolute; left: 20px; top: 20px;
}
.controls .control { margin: 0px 0px 10px 0px;
}
.controls .val { float: right; margin-left: 20px;
}
body { background: black; color: white;
}
Time Dilation - Script Codes JS Codes
var layers = document.querySelector('.layers');
var layersInput = document.querySelector('#layers');
var offsetInputX = document.querySelector('#offset-x');
var offsetInputY = document.querySelector('#offset-y');
var dilation = document.querySelector('#dilation');
var controls = Array.prototype.slice.apply(document.querySelectorAll('.control'));
var render = function(){ layers.innerHTML = ''; var layerIndex = layersInput.value; while(layerIndex){ var layer = document.createElement('div'); layers.appendChild(layer); layer.className = 'layer'; layerIndex --; } update();
}
var update = function(){ console.log('update'); Array.prototype.slice.apply(layers.querySelectorAll('.layer')).forEach(function(layer, layerIndex){ console.log(layerIndex) var numLayers = layersInput.value; var size = layerIndex/numLayers * 100; layer.style.width = size + '%'; layer.style.height = size + '%'; layer.style.backgroundSize = 640 + (1-layerIndex/numLayers) * dilation.value + 'px'; layer.style.backgroundPositionX = layerIndex/numLayers * offsetInputX.value + '%'; layer.style.backgroundPositionY = layerIndex/numLayers * offsetInputY.value + '%'; layer.style.zIndex = numLayers - layerIndex; }); controls.forEach(function(control, i){ var val = control.querySelector('input').value; control.querySelector('.val').innerHTML = val; });
}
layersInput.addEventListener('change', render);
offsetInputX.addEventListener('input', update);
offsetInputY.addEventListener('input', update);
dilation.addEventListener('input', update);
render();
Developer | Josh Beckwith |
Username | positlabs |
Uploaded | August 29, 2022 |
Rating | 3 |
Size | 3,166 Kb |
Views | 26,312 |
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 |
A Pen by Josh Beckwith | 2,313 Kb |
Spherical orbiter | 3,870 Kb |
HammerJS Test | 1,767 Kb |
Blurry text | 1,754 Kb |
Emoji Split with spliddit | 2,156 Kb |
Punch Button | 3,958 Kb |
JitterSCSS | 4,712 Kb |
Fly Eye CSS | 8,718 Kb |
Youtube 360 player sandbox | 2,195 Kb |
Temporalis | 1,842 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 |
Siema - add pagination to prototype | Pawelgrzybek | 2,575 Kb |
TinFoil Boats | Chandralil | 4,577 Kb |
Off Canvas | Mariamarica | 1,870 Kb |
Javascript Welcome | Peterlewicki | 1,573 Kb |
Text Looping Transition | Agelber | 5,619 Kb |
Rows with image hover effect | Amit-webdesigner | 12,875 Kb |
Mobile Nav Menu | AliKlein | 4,745 Kb |
Polygon Dodecahedron in CSS | Vennsoh | 7,606 Kb |
Animating characters with jQuery | 042 | 2,776 Kb |
Bootstrap Responsive Menu Drawer | JesseGlacken | 3,777 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!