#codevember #9 Parallax Squares
How do I make an #codevember #9 parallax squares?
What is a #codevember #9 parallax squares? How do you make a #codevember #9 parallax squares? This script and codes were developed by Johan Karlsson on 26 July 2022, Tuesday.
#codevember #9 Parallax Squares - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>#codevember #9 Parallax Squares</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas>
<h3 id="instructions"> Move mouse or touch
</h3> <script src="js/index.js"></script>
</body>
</html>
#codevember #9 Parallax Squares - Script Codes CSS Codes
@import url(https://fonts.googleapis.com/css?family=Noto+Sans);
* { font-family: 'Noto Sans', sans-serif;
}
html, body { background-color: beige; margin: 0;
}
canvas { display: block;
}
#instructions { color: #333; position: fixed; top: 0; margin-left: 20px;
}
#codevember #9 Parallax Squares - Script Codes JS Codes
/* Johan Karlsson (DonKarlssonSan) All my #codevember Pens: http://codepen.io/collection/XwMkWm/
*/
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var width = canvas.width = window.innerWidth;
var height = canvas.height = window.innerHeight;
var min = Math.min(width, height);
ctx.fillStyle = "rgba(33, 33, 33, 0.3)";
var angle = 0;
var x = 0, y = 0;
function draw() { drawRect(0.1); drawRect(0.15); drawRect(0.2); drawRect(0.25); drawRect(0.3); drawRect(0.35); drawRect(0.4);
}
function drawRect(factor) { ctx.save(); // The offsets become 0 when x and y are center // of screen. // Bigger factor => smaller offset var xOffset = (0.5-x/width)*50/factor; var yOffset = (0.5-y/height)*50/factor; ctx.translate(width/2 + xOffset, height/2 + yOffset); ctx.rotate(angle/factor*0.05); ctx.fillRect(-min*(0.5-factor), -min*(0.5-factor), min*(1-factor*2), min*(1-factor*2)); ctx.restore();
}
function onMove(e) { // Get position from touch or mouse x = e.touches ? e.touches[0].clientX : e.clientX; y = e.touches ? e.touches[0].clientY : e.clientY; // x/width is between 0 and 1 // 0.5 - x/width is between -0.5 and 0.5, so that // we rotate both clockwise and counterclockwise angle = 0.5 - x/width;
}
canvas.addEventListener("mousemove", onMove);
canvas.addEventListener("touchmove", onMove);
function animate() { ctx.clearRect(0, 0, width, height); requestAnimationFrame(animate); draw();
}
animate();
Developer | Johan Karlsson |
Username | DonKarlssonSan |
Uploaded | July 26, 2022 |
Rating | 4.5 |
Size | 2,370 Kb |
Views | 50,600 |
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 |
Phone Case Pattern Animation | 2,774 Kb |
Cash by Brownian Motion | 3,530 Kb |
Rainbow 6-fold Pentille | 4,311 Kb |
Fireflies | 2,572 Kb |
Lissajous x Lissajous | 3,369 Kb |
Apply Filter Effects to Music | 4,027 Kb |
Particle Text | 5,685 Kb |
Circuit Board Warper | 4,057 Kb |
Random Fractal | 2,751 Kb |
Diffusion-Limited Aggregation - Line | 2,550 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 |
Flex Chart | James_zedd | 4,111 Kb |
Template | Indra_z85 | 2,323 Kb |
TheCalendar.js | The-teacher | 6,330 Kb |
VerbalExpressions Converter | Cmalven | 2,607 Kb |
Twitch | SarahDunlap | 2,937 Kb |
Responsive scrolling text | Ashdurham | 2,259 Kb |
Collapsing Widget | Er40 | 4,279 Kb |
Easing | GreenSock | 2,043 Kb |
SVG Icons Template | Legofsalmon | 2,618 Kb |
Simple Linear Regression with Editable Table | Melatonind | 3,264 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!