A Pen by Khangeldy

Developer
Size
2,352 Kb
Views
12,144

How do I make an a pen by khangeldy?

What is a a pen by khangeldy? How do you make a a pen by khangeldy? This script and codes were developed by Khangeldy on 09 November 2022, Wednesday.

A Pen by Khangeldy Previews

A Pen by Khangeldy - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>A Pen by Khangeldy</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
</head>
<body> <canvas id="tutorial" width="500" height="500"></canvas> <script src="js/index.js"></script>
</body>
</html>

A Pen by Khangeldy - Script Codes JS Codes

var canvas = document.getElementById('tutorial'),	context = canvas.getContext('2d'),	w = canvas.width = window.innerWidth,	h = canvas.height = window.innerHeight,	area = w * h,	particleNum = 300,	ANIMATION,	particleStartX = w / 2,	particleStartY = h / 2;
var particles = [];
// Particle constructor
function Particle(i) {	this.id = i;	this.hue = rand(50,0, 1);	this.active = false;
}
Particle.prototype.build = function(parX, parY) {	//	window center	this.x = parX;	this.y = parY;	// random	this.r = rand(7, 2, 1);	this.vx = Math.random() * 10 - 5;	this.vy = Math.random() * 10 - 5;	this.gravity = .01;	this.opacity = Math.random() + .5;	this.active = true;	context.beginPath();	context.arc(this.x, this.y, this.r, 0, 2 * Math.PI, false);	context.fillStyle ="hsla(" + this.hue + ",100%,50%,1)";	context.fill();
};
Particle.prototype.draw = function() {	this.active = true;	this.x += this.vx;	this.y += this.vy;	this.vy += this.gravity;	this.hue -= 0.5;	this.r = Math.abs(this.r - 0.05);	context.beginPath();	context.arc(this.x, this.y, this.r, 0, 2 * Math.PI, false);	context.fillStyle = "hsla(" + this.hue + ", 100%, 50%, 1)";	context.fill();	if(this.r <= 0.5) {	this.active = false;	}
}
// draw scene
function drawScene() {	context.fillStyle = 'black';	context.fillRect(0,0,w,h);	for(var i = 0; i < particles.length; i++) {	if(particles[i].active === true) {	particles[i].draw();	} else {	particles[i].build(particleStartX, particleStartY);	}	}	ANIMATION = requestAnimationFrame(drawScene);
}
function initCanvas() {	var s = getComputedStyle(canvas);	if(particles.length) {	particles = [];	cancelAnimationFrame(ANIMATION);	ANIMATION;	console.log(ANIMATION);	}	w = canvas.width = window.innerWidth;	h = canvas.height = window.innerHeight;	for(var i = 0; i < particleNum; i++) {	particles.push(new Particle(i));	}	drawScene();	console.log(ANIMATION);
}
(function init() {	initCanvas();	window.addEventListener('resize', initCanvas, false);	document.addEventListener('mousemove', function(e) {	if(e.pageY <= 10 || e.pageY > window.innerHeight || e.pageX <= 10 || e.pageX > window.innerWidth ) {	console.log('out');	particleStartY = h / 2;	particleStartX = w / 2;	} else {	particleStartX = e.pageX;	particleStartY = e.pageY;	}	});
})();
// Helper Functions
function rand(max, min, _int) {	var max = (max === 0 || max) ? max: 1,	min = min || 0,	gen = min + (max -min) * Math.random();	return (_int) ? Math.round(gen) : gen;
}
A Pen by Khangeldy - Script Codes
A Pen by Khangeldy - Script Codes
Home Page Home
Developer Khangeldy
Username Khangeldy
Uploaded November 09, 2022
Rating 3
Size 2,352 Kb
Views 12,144
Do you need developer help for A Pen by Khangeldy?

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!

Khangeldy (Khangeldy) Script Codes
Create amazing sales emails 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!