Phone Case Pattern Animation
How do I make an phone case pattern animation?
This animation is inspired by the phone case I bought today:. What is a phone case pattern animation? How do you make a phone case pattern animation? This script and codes were developed by Johan Karlsson on 30 October 2022, Sunday.
Phone Case Pattern Animation - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Phone Case Pattern Animation</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>
Phone Case Pattern Animation - Script Codes CSS Codes
html, body { margin: 0;
}
canvas { display: block;
}
Phone Case Pattern Animation - Script Codes JS Codes
"use strict";
/* Johan Karlsson (DonKarlssonSan)
*/
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var width = canvas.width = window.innerWidth;
var height = canvas.height = window.innerHeight;
ctx.lineCap = "round";
ctx.lineWidth = 2;
var phi = 0;
var tick = 0;
function drawSection(x, y, angle, color) { ctx.save(); ctx.fillStyle = color; ctx.translate(x, y); ctx.rotate(angle + phi); ctx.beginPath(); ctx.moveTo(0, 0); ctx.lineTo(100, -57.8); ctx.lineTo(50, -87); ctx.lineTo(0, -58); ctx.lineTo(-50, -87); ctx.lineTo(-100, -57.8); ctx.lineTo(0, 0); ctx.stroke(); ctx.fill(); ctx.restore();
}
function drawOne(x, y) { drawSection(x, y, 0, "palegreen"); drawSection(x, y, 2 * Math.PI / 3, "pink"); drawSection(x, y, 4 * Math.PI / 3, "white");
}
function draw() { ctx.clearRect(0, 0, width, height); requestAnimationFrame(draw); var col = width / 300; var row = height / 150; for (var x = 0; x < col; x++) { for (var y = 0; y < row; y++) { drawOne(x * 300, y * 174); drawOne(x * 300 + 150, y * 174 + 88); } } phi = Math.cos(tick) * 1.051 * 3 + Math.PI; tick += 0.004;
}
draw();
Developer | Johan Karlsson |
Username | DonKarlssonSan |
Uploaded | October 30, 2022 |
Rating | 4 |
Size | 2,774 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 |
Laser Writer | 6,065 Kb |
Wayward Walker Worms | 3,123 Kb |
Photobooth - Webcam with realtime CSS filters. | 4,390 Kb |
Portrait by Brownian Motion | 3,612 Kb |
Cash by Brownian Motion | 3,530 Kb |
Circle Fractal | 2,482 Kb |
Rainbow 6-fold Pentille | 4,311 Kb |
Diffusion-Limited Aggregation - Line | 2,550 Kb |
Moss by Brownian Motion | 2,792 Kb |
Rotating Neon Curves | 3,770 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 |
Shopping cart | Andiio | 6,581 Kb |
Donald Trump - The New Yorker | Agbales | 2,502 Kb |
JQuery Validate checkbox group | Lunaman | 2,466 Kb |
Slide In Panel | Vikvarg | 2,811 Kb |
JQuery AJAX reddit Exercise | Btholt | 1,777 Kb |
A Pen by John Malc | F789gh | 1,420 Kb |
A Pen by Kenny Mark | Kennymark | 5,574 Kb |
Matrix | Stathisnikolaidis | 1,922 Kb |
CodeCamp Tribute Page | JonathanDeJesus | 6,860 Kb |
Alter bg opacity on hover... | Chrisboon27 | 2,054 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!