Color Chaos

Developer
Size
4,129 Kb
Views
26,312

How do I make an color chaos?

Move your mouse to create mess and stuff =). What is a color chaos? How do you make a color chaos? This script and codes were developed by Godje on 12 September 2022, Monday.

Color Chaos Previews

Color Chaos - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Color Chaos</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <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 id="canvas"></canvas> <script src='https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.1/dat.gui.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/stats.js/r16/Stats.min.js'></script>
<script src='js/abbjza.js'></script> <script src="js/index.js"></script>
</body>
</html>

Color Chaos - Script Codes CSS Codes

* { box-sizing: border-box;
}
canvas { position: absolute; top: 0; left: 0;
}
body { overflow: hidden;
}

Color Chaos - Script Codes JS Codes

(function(){	var canvasBody = document.getElementById("canvas"),	canvas = canvasBody.getContext("2d"),	w = canvasBody.width = window.innerWidth,	h = canvasBody.height = window.innerHeight,	pi2 = Math.PI*2,	tick = 0,	opts = {	canvas: {	backgroundColor: "#222"	},	affRad: 50,	size: 5,	spacing: 20,	color: "#fcfcfc",	speedLimit: 5,	showFPS: false,	populate: function(){	var spacing = opts.spacing;	particles = [];	for(var x = spacing/2; x<w; x+=spacing){	for(var y = spacing/2; y<h; y+=spacing){	particles.push(new Particle(x,y));	}	}	}	},	Colors = [	"#2ecc71", //green	"#3498db", //blue	"#e67e22", //orange	"#e74c3c", //red	"#ecf0f1", //white	"#9b59b6", //purple	"#2c3e50", //night-blue	],	gui = new dat.GUI(),	particles = [],	Mouse = new Vector2(w/2, h/2),	Particle = function(X, Y){	this.pos = new Vector2(X||0, Y||0);	this.speed = new Vector2();	this.acc = new Vector2();	this.color = Colors[Math.floor(Math.random()*Colors.length)];	};	Particle.prototype.update = function(){	this.border();	this.speed.add(this.acc);	this.pos.add(this.speed);	this.acc.set(0);	return this;	}	Particle.prototype.border = function(){	0 > this.pos.x ? (this.speed.x*=-1, this.pos.x = 0) :undefined;	w < this.pos.x ? (this.speed.x*=-1, this.pos.x = w-opts.size) :undefined;	0 > this.pos.y ? (this.speed.y*=-1, this.pos.y = 0) :undefined;	h < this.pos.y ? (this.speed.y*=-1, this.pos.y = h-opts.size) :undefined;	}	Particle.prototype.force = function(f){	var tar = f.copy();	this.acc.add(tar);	return this;	}	Particle.prototype.runAway = function(t){	if(this.pos.distanceTo(t) < opts.affRad){	var tar = t.copy();	tar.sub(this.pos);	tar.mult(-1);	var desired = tar.sub(this.speed);	tar.limit(opts.speedLimit);	this.force(desired);	}	this.speed.limit(opts.speedLimit)	this.speed.div(1.05);	return this;	}	Particle.prototype.render = function(){	var size = opts.size;	canvas.fillStyle = this.color;	canvas.beginPath();	canvas.arc(this.pos.x, this.pos.y, opts.size, 0, pi2);	canvas.fill();	//canvas.fillRect(this.pos.x, this.pos.y, size, size);	return this;	}	function setup(){	//SETING UP FOR MOBILE	if(w < 768){	opts.spacing = 11;	opts.size = 5;	opts.affRad = 35;	gui.close();	}	opts.populate();	stats = new Stats();	stats.showPanel( 0 );	gui.add(opts, "size", 0.5, 100);	gui.add(opts, "spacing", opts.size, 200).onFinishChange(opts.populate);	gui.add(opts, "affRad", 10, Math.min(w,h)/2);	gui.add(opts, "showFPS");	gui.add(opts, 'populate').name("reset()")	stats.domElement.className="ST";	document.body.appendChild( stats.domElement );	window.requestAnimationFrame(loop);	};	function loop(){	stats.begin();	canvas.fillStyle = opts.canvas.backgroundColor;	canvas.fillRect(0,0,w,h);	particles.map(function(P){	P.runAway(Mouse).update().render();	});	opts.showFPS ? document.querySelector(".ST").style.display = "block" : document.querySelector(".ST").style.display = "none";	window.requestAnimationFrame(loop);	stats.end();	};	setup();	window.addEventListener("resize", function(){	w = canvasBody.width = window.innerWidth;	h = canvasBody.height = window.innerHeight;	opts.populate();	});	canvasBody.addEventListener("mousemove", function(e){	Mouse.x = e.pageX;	Mouse.y = e.pageY;	});	canvasBody.addEventListener("touchstart", function(e){	e.preventDefault();	var touches = e.changedTouches;	Mouse.set(touches[0].pageX, touches[0].pageY)	});	canvasBody.addEventListener("touchmove", function(e){	var touches = e.changedTouches;	Mouse.set(touches[0].pageX, touches[0].pageY);	});	canvasBody.addEventListener("touchend", function(e){	Mouse.set(-opts.affRad, - opts.affRad);	});
})();
Color Chaos - Script Codes
Color Chaos - Script Codes
Home Page Home
Developer Godje
Username Godje
Uploaded September 12, 2022
Rating 4.5
Size 4,129 Kb
Views 26,312
Do you need developer help for Color Chaos?

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!

Godje (Godje) Script Codes
Create amazing SEO content with AI!

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!