FIRE

Developer
Size
3,636 Kb
Views
34,408

How do I make an fire?

What is a fire? How do you make a fire? This script and codes were developed by Godje on 12 September 2022, Monday.

FIRE Previews

FIRE - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>FIRE</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 id="canvas"></canvas>
<h1 id="fayar">FIRE</h1> <script src="js/index.js"></script>
</body>
</html>

FIRE - Script Codes CSS Codes

@import url("https://fonts.googleapis.com/css?family=Shadows+Into+Light");
canvas { position: absolute; top: 0; left: 0; z-index: -1;
}
body { position: relative; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; margin: 0; height: 100vh; font-family: "Shadows into light"; text-shadow: 0px 0px 30px rgba(255, 165, 0, 0.3);
}
#fayar { position: absolute; margin: 0; color: orange; font-size: 100px; z-index: 1;
}

FIRE - Script Codes JS Codes

(function(){	var canvasBody = document.getElementById("canvas"),	canvas = canvasBody.getContext("2d"),	w = canvasBody.width = window.innerWidth,	h = canvasBody.height = window.innerHeight,	tick = 0,	opts = {	canvas: {	backgroundColor: "#100505",	fireAmount: w/35	},	fire: {	height: h/3,	sparksAmount: 10,	speed: 70,	addedSpeed: 20,	defaultWidth: 40,	minWidthIncrement: 40,	addedWidthIncrement: 20,	minSparkHeightIncrement: 40,	addedSparkHeightIncrement: 20	},	spark: {	color: "hsla(hue,100%,40%,alpha)",	startSize: 50,	hueChange: 35	}	},	fires = [],	Fire = function(obj){	this.sparks = [];	this.x = obj.x;	this.y = obj.y;	this.height = h - obj.y;	this.init = function(){	this.sparksAmount = Math.floor(obj.sparksAmount);	this.sizeDecrement = this.height / opts.spark.startSize / 100;	for(var i = 0; i < this.sparksAmount; i++){	this.sparks.push( new Spark({	x: 0, //relative to the fire	y: 20, //relative to the fire	sizeDecrement: this.sizeDecrement,	xIncrement: opts.fire.minWidthIncrement + Math.random()*opts.fire.addedWidthIncrement,	yIncrement: h*3 /opts.fire.minSparkHeightIncrement + Math.random()*opts.fire.addedSparkHeightIncrement,	delay: 10*i	}));	}	};	this.update = function(){	this.sparks.map( function(Spark){	Spark.update();	});	};	this.render = function(){	var coords = [this.x, this.y + this.height]	this.sparks.map( function(Spark){	Spark.render(coords[0], coords[1]);	});	};	this.init(obj);	},	Spark = function(obj){	this.x = obj.x;	this.y = obj.y;	this.delay = obj.delay;	this.direction = Math.random() < 0.5 ? 1 : -1	this.xIncrement = obj.xIncrement;	this.yIncrement = obj.yIncrement;	this.sizeDecrement = obj.sizeDecrement;	this.size = opts.spark.startSize;	this.phaseTime = opts.fire.speed + Math.random()*opts.fire.addedSpeed;	this.hueFactor = opts.spark.hueChange / this.phaseTime;	this.alphaFactor = 1 / this.phaseTime;	this.time = obj.delay;	this.pathPoints = [];	this.color = opts.spark.color;	this.equation = function(){};	this.update = function(){	this.size -= this.sizeDecrement;	this.time > this.phaseTime ? this.restart() : this.time++;	var r = 360 / this.phaseTime,	e = r * this.time;	this.color = opts.spark.color;	this.color = this.color.replace("hue", 30 - this.hueFactor * this.time);	this.color = this.color.replace("alpha", 1.25 - this.alphaFactor * this.time);	this.x = this.equation(e)[0];	this.y = this.equation(e)[1];	};	this.render = function(x, y){	canvas.beginPath();	canvas.arc(this.x + x, this.y + y, Math.abs(this.size), 0, Math.PI*2);	canvas.closePath();	canvas.fillStyle = this.color;	canvas.fill()	};	this.start = function(){	this.time = this.delay;	this.size = opts.spark.startSize;	this.sizeDecrement = opts.spark.startSize / this.phaseTime;	this.equation = function(x){	var X = Math.radians(x);	return [Math.sin(X) * this.xIncrement * this.direction, -X * this.yIncrement];	}	};	this.restart = function(){	this.time = 0;	this.size = opts.spark.startSize;	this.color = opts.spark.color;	}	this.start();	};	Math.radians = function(deg){	return deg * (Math.PI / 180);	}	function setup(){	for(var i = 0; i < opts.canvas.fireAmount; i++){	fires.push( new Fire({	x: w/opts.canvas.fireAmount * i,	y: h - opts.fire.height - Math.random()*(opts.fire.height/3),	sparksAmount: opts.fire.sparksAmount + Math.random()*(opts.fire.sparksAmount/2)	}));	}	fires.map( function(Fire){	Fire.init();	Fire.update();	});	window.requestAnimationFrame(loop);	};	function loop(){	canvas.fillStyle = opts.canvas.backgroundColor;	canvas.fillRect(0,0,w,h);	tick++;	fires.map( function(Fire){	Fire.update();	Fire.render();	});	window.requestAnimationFrame(loop);	};	setup();	window.addEventListener("resize", function(){	w = canvasBody.width = window.innerWidth;	h = canvasBody.height = window.innerHeight;	});
})();
FIRE - Script Codes
FIRE - Script Codes
Home Page Home
Developer Godje
Username Godje
Uploaded September 12, 2022
Rating 4
Size 3,636 Kb
Views 34,408
Do you need developer help for FIRE?

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 web 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!