Magic circle4
How do I make an magic circle4?
What is a magic circle4? How do you make a magic circle4? This script and codes were developed by Takashi on 20 October 2022, Thursday.
Magic circle4 - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>magic circle4</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Magic circle4 - Script Codes CSS Codes
html,body{ margin: 0; overflow: hidden; }
Magic circle4 - Script Codes JS Codes
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var windowW = window.innerWidth;
var windowH = window.innerHeight;
var centerW = windowW / 2;
var centerH = windowH / 2;
var circle = undefined;
var circles = [];
var shortSide = undefined;
function setup() { shortSide = min(windowW, windowH); createCanvas(windowW, windowH); background(0); for (var i = 0; i < 12; i++) { circle = new MagicCircle(floor(random(6, 40)), centerW, centerH, random(shortSide / 2 * 0.6, shortSide / 2 * 0.8), color(random(20, 255), random(20, 255), random(20, 255), 255)); circles.push(circle); }
}
function draw() { blendMode(ADD); clear(); background(0); noFill(); circles.forEach(function (circle) { circle.update(); circle.display(); });
}
var Particle = function () { function Particle(x, y, w, h, r) { _classCallCheck(this, Particle); this.pos = createVector(x, y); this.w = w; this.h = h; this.r = r; } Particle.prototype.display = function display() { noFill(); noStroke(); fill(0); ellipse(this.pos.x, this.pos.y, this.r, this.r); }; return Particle;
}();
var MagicCircle = function () { function MagicCircle(len, x, y, r, c) { _classCallCheck(this, MagicCircle); this.pArr = []; this.pos = createVector(x, y); this.tempPos = createVector(x, y); this.r = r; this.len = len; this.tx = random(500); this.ty = random(500); this.tPos = random(500); this.txSpeed = random() / 30; this.tySpeed = random() / 30; this.rotation = 0; this.rotateSpeed1 = random(0.1, 1); this.rotateSpeed2 = random(0.1, 2); this.color = c; this.fPoints = random(shortSide / 2 * 0.01, shortSide / 2 * 0.3); this.fPos = random(shortSide / 2 * 0.04, shortSide / 2 * 0.3); this.w = random(1, 3); for (var i = 0; i < len; i++) { var p = new Particle(x, y, 2, 10, 4); this.pArr.push(p); } } MagicCircle.prototype.update = function update() { this.tx += this.txSpeed; this.ty += this.tySpeed; this.rotation = this.rotation % 360; this.rotation += this.rotateSpeed1; // points position in circle for (var i = 0; i < this.len; i++) { var rad = radians(360 / this.len * i); var x = cos(rad) * (this.r + noise(this.tx + i) * this.fPoints); var y = sin(rad) * (this.r + noise(this.ty + i) * this.fPoints); this.pArr[i].pos.x = x; this.pArr[i].pos.y = y; } // circle position this.tPos = this.tPos % 360; this.tPos += this.rotateSpeed2; this.pos.x = cos(radians(this.tPos)) * this.fPos * noise(this.tx / 10) + this.tempPos.x; this.pos.y = sin(radians(this.tPos)) * this.fPos * noise(this.ty / 10) + this.tempPos.y; }; MagicCircle.prototype.display = function display() { push(); translate(this.pos.x, this.pos.y); rotate(radians(this.rotation)); stroke(this.color); strokeWeight(this.w); noFill(); beginShape(); curveVertex(this.pArr[this.len - 1].pos.x, this.pArr[this.len - 1].pos.y); for (var i = 0; i < this.len; i++) { curveVertex(this.pArr[i].pos.x, this.pArr[i].pos.y); } curveVertex(this.pArr[0].pos.x, this.pArr[0].pos.y); curveVertex(this.pArr[1].pos.x, this.pArr[1].pos.y); endShape(); // for (let i = 0; i< this.len; i++) { // this.pArr[i].display(); // } pop(); }; return MagicCircle;
}();
Developer | Takashi |
Username | tksiiii |
Uploaded | October 20, 2022 |
Rating | 3 |
Size | 3,638 Kb |
Views | 12,144 |
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 |
Lines circle | 1,959 Kb |
Noise curve 2D | 3,551 Kb |
Polar Rose Generator | 5,055 Kb |
Colorful 2D particle attractor | 2,841 Kb |
Mosaic Pixel Effect | 358,869 Kb |
Magic circle5 | 3,614 Kb |
Wave2D | 4,772 Kb |
Magic circle3 | 3,584 Kb |
Glittering particle | 2,058 Kb |
Colorful smoke | 2,247 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 |
Side Sliding Menu CSS | EduardL | 4,388 Kb |
Long Shadow Button | Uixcrazy | 3,550 Kb |
3d css cube | Semenchenko | 4,578 Kb |
Konami Code Easter Egg | Teolitto | 3,051 Kb |
Flex layout example | Mofny | 1,663 Kb |
Menubar compass mixin | Michaelparenteau | 4,925 Kb |
Twitch Live Channels | Inkblotty | 4,956 Kb |
Starfield old school style | Bolloxim | 5,214 Kb |
CSS Patterns | Alyda | 3,953 Kb |
React JS Movie Info App | MTushar | 4,870 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!