Superformula
How do I make an superformula?
See https://en.wikipedia.org/wiki/Superformula. What is a superformula? How do you make a superformula? This script and codes were developed by Aitor on 16 September 2022, Friday.
Superformula - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Superformula</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>
<canvas width="640" height="480"></canvas> <script src="js/index.js"></script>
</body>
</html>
Superformula - Script Codes CSS Codes
html,
body { background: #000; color: #fff; margin: 0; padding: 0; font-family: Lato, sans-serif;
}
Superformula - Script Codes JS Codes
"use strict";
// @see: https://en.wikipedia.org/wiki/Superformula
var canvas = document.querySelector("canvas"), context = canvas.getContext("2d");
var SCALE = 150;
var VALUES = [];
for (var index = 0; index < 30; index++) { VALUES.push(Math.random() * 20000 + 100);
}
function superformula(phi, a, b, m, n1, n2, n3) { return Math.pow(Math.pow(Math.abs(Math.cos(m * phi / 4) / a), n2) + Math.pow(Math.abs(Math.sin(m * phi / 4) / b), n3), -1 / n1);
}
function renderFormula(now, t1, t2, t3, i) { var s1 = now / t1; var s2 = now / t2; var s3 = now / t3; var a = Math.abs(Math.sin(s1)); var b = Math.abs(Math.sin(s1)); var m = Math.abs(Math.sin(s2) * 50); var n1 = Math.abs(Math.sin(s3) * 50); var n2 = Math.abs(Math.sin(s2) * 50); var n3 = Math.abs(Math.sin(s1) * 50); context.beginPath(); for (var index = 0; index < 360; index++) { var radius = superformula(index / 360 * Math.PI * 2, a, b, m, n1, n2, n3); var x = Math.cos(index / 360 * Math.PI * 2) * radius * SCALE; var y = Math.sin(index / 360 * Math.PI * 2) * radius * SCALE; if (index === 0) { context.moveTo(x, y); } else { context.lineTo(x, y); } } context.closePath(); context.globalCompositeOperation = "lighten"; context.shadowColor = "#0cf"; context.shadowBlur = 32; context.lineWidth = i; context.strokeStyle = "#fff"; context.stroke();
}
function update() {}
function render(now) { var s1 = now / 1000; var s2 = now / 250; var s3 = now / 500; var a = Math.abs(Math.sin(s1)); var b = Math.abs(Math.sin(s1)); var m = Math.abs(Math.sin(s2) * 50); var n1 = Math.abs(Math.sin(s3) * 50); var n2 = Math.abs(Math.sin(s2) * 50); var n3 = Math.abs(Math.sin(s1) * 50); context.clearRect(0, 0, canvas.width, canvas.height); context.save(); context.translate(canvas.width * 0.5, canvas.height * 0.5); for (var index = 0; index < VALUES.length; index += 3) { renderFormula(now, VALUES[index], VALUES[index + 1], VALUES[index + 2], index + 1); } context.restore();
}
function frame(now) { update(); render(now); window.requestAnimationFrame(frame);
}
function resize() { canvas.width = window.innerWidth; canvas.height = window.innerHeight;
}
window.requestAnimationFrame(frame);
window.addEventListener("resize", resize);
window.dispatchEvent(new Event("resize"));
Developer | Aitor |
Username | AzazelN28 |
Uploaded | September 16, 2022 |
Rating | 4 |
Size | 3,671 Kb |
Views | 40,480 |
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 |
Worm | 5,062 Kb |
Break Out | 12,431 Kb |
Fire | 3,542 Kb |
Asteroids | 13,025 Kb |
Blending Experiment 29 | 7,996 Kb |
AudioContext Concept | 3,112 Kb |
Circuitry | 2,541 Kb |
Date Input | 10,870 Kb |
Shadowing without intersecting | 4,645 Kb |
Dancing Text | 3,761 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 |
Price table | Serluk | 5,928 Kb |
Hamburger Menu Animation | Salmanraza | 2,580 Kb |
The Monty Hall Problem | Melatonind | 4,360 Kb |
Webkit decolorize | Fivera | 1,675 Kb |
CSS Variables | Jdsteinbach | 4,759 Kb |
CSS only simple parallax scroll | Stanssongs | 3,708 Kb |
Kut D3 | Jellevrswk | 3,687 Kb |
Custom Checkbox and radio inputs SCSS | Rgfx | 3,367 Kb |
Prism | Pyrografix | 2,843 Kb |
Caputre Cam with JS | KimmoCommit | 2,795 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!