Higgs-Boson

Developer
Size
2,782 Kb
Views
28,336

How do I make an higgs-boson?

Searching for the Higgs-Boson. Click to clear canvas. Update: Added some mouse interaction.. What is a higgs-boson? How do you make a higgs-boson? This script and codes were developed by Tristan on 25 August 2022, Thursday.

Higgs-Boson Previews

Higgs-Boson - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Higgs-Boson</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Higgs-Boson - Script Codes CSS Codes

*{margin:0;padding:0;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}
body{font-size:75%;background:#222;font-family:arial;padding:20px 0 0 20px}
canvas{border:1px solid #181818;display:block;box-shadow:0 0 10px #111}

Higgs-Boson - Script Codes JS Codes

	var canvas, c, w, h, halfX, halfY,	twoPI = Math.PI * 2,	mX, mY, mousedown, higgsboson;	window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();	window.onload = function(){	canvas = document.createElement('canvas')	w = canvas.width = window.innerWidth - 40;	h = canvas.height = window.innerHeight - 40;	c = canvas.getContext('2d');	halfX = w/2;	halfY = h/2;	document.body.appendChild(canvas);	window.addEventListener('resize', function(e){	w = canvas.width = window.innerWidth - 40;	h = canvas.height = window.innerHeight - 40;	halfX = w/2;	halfY = h/2;	});	canvas.addEventListener('mousemove', function(e){ mX = e.pageX-20; mY = e.pageY-20; });	canvas.addEventListener('mousedown', function(e){ mousedown = true; });	canvas.addEventListener('mouseup', function(e){ mousedown = false; });	higgsboson = new Explode(50);	}	function Explode(count){	var points = [];	var animID = null;	function Point(){	this.x = halfX; //Math.random()*w;	this.y = halfY; //Math.random()*h;	this.d = Math.random()*10-5;	this.dd = (Math.random()*1-0.5)/100;	this.a = Math.random()*twoPI;	this.ad = (Math.random()*twoPI-Math.PI) / 128;	this.alpha = 0;	}	function init(count){	for(var p = 0; p < count; p++){	points.push(new Point());	}	animate();	}	function update(){	for(var p = 0; p < points.length; p++){	if(points[p].alpha < 1)	points[p].alpha += 0.01;	var xd = mX - points[p].x,	yd = mY - points[p].y,	md = Math.sqrt(xd * xd + yd * yd),	ma = Math.atan2(yd, xd);	if(md < 100)	points[p].a = ma;	points[p].a += points[p].ad;	points[p].d += points[p].dd;	points[p].x += Math.cos(points[p].a) * points[p].d;	points[p].y += Math.sin(points[p].a) * points[p].d;	if(points[p].x > w){	points[p] = new Point();	continue;	}	if(points[p].x < 0){	points[p] = new Point();	continue;	}	if(points[p].y > h){	points[p] = new Point();	continue;	}	if(points[p].y < 0){	points[p] = new Point();	continue;	}	}	}	function draw(){	for(var p = 0; p < points.length; p++){	c.fillStyle = "hsla(" + (points[p].x/w * 360) + ",50%,50%," + points[p].alpha + ")";	c.beginPath();	c.arc(points[p].x, points[p].y, Math.abs(points[p].dd)*1000, 0, twoPI, false);	c.closePath();	c.fill();	for(var p2 = p; p2 < points.length; p2++){	var dx = points[p2].x - points[p].x,	dy = points[p2].y - points[p].y,	dd = Math.sqrt(dx * dx + dy * dy);	if(dd < 100){	c.beginPath();	c.moveTo(points[p].x, points[p].y);	c.lineTo(points[p2].x, points[p2].y);	c.strokeStyle = "hsla(" + (points[p].x/w * 360) + ",50%,50%," + (1-(dd/50)) + ")";	c.stroke();	}	}	}	}	function clear(){	if(mousedown){	c.clearRect(0,0,w,h);	return;	}	c.save();	c.fillStyle = "rgba(0,0,0,0.01)";	c.fillRect(0,0,w,h);	c.restore();	}	function animate(){	update();	clear();	draw();	requestAnimFrame(animate);	}	init(count);	}
Higgs-Boson - Script Codes
Higgs-Boson - Script Codes
Home Page Home
Developer Tristan
Username sinthetyc
Uploaded August 25, 2022
Rating 4
Size 2,782 Kb
Views 28,336
Do you need developer help for Higgs-Boson?

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!

Tristan (sinthetyc) Script Codes
Create amazing art & images 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!