Curved fractal

Developer
Size
2,430 Kb
Views
24,288

How do I make an curved fractal?

What is a curved fractal? How do you make a curved fractal? This script and codes were developed by Findoff on 03 October 2022, Monday.

Curved fractal Previews

Curved fractal - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>curved fractal</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.5.1/dat.gui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Curved fractal - Script Codes JS Codes

document.addEventListener('DOMContentLoaded', function(){	/* i love DOM */	var canvas = document.createElement('canvas');	document.body.appendChild(canvas);	document.body.style.padding = '0px';	document.body.style.margin = '0px';	document.body.style.overflow = 'hidden';	/* i love full screen */	var w = canvas.width = window.innerWidth;	var h = canvas.height = window.innerHeight;	var ctx = canvas.getContext('2d');	/* i love bad short opts ^__^ like q or qwe */	var opts = {	};	var gui = new dat.GUI();	function opt(name, value, min, max){	opts[name] = value;	return gui.add(opts, name, min, max);	}	/*	if code.before > ugly -> just.dont.read(below) // below worse...	==== let's begin. ====	*/	opt('rect', true);	opt('s', 0.216, 0.01, 0.36).random = true;	opt('s2', 0.25, 0, 0.5).random = true;	opt('s3', 0.5, 0, 2).random = true;	opt('limit', 5, 1, 8).step(1);	opt('random', true);	opt('speed', 0.05, 0, 1);	function lerp2(a, b, p, s){	var x = b[0]-a[0];	var y = b[1]-a[1];	return [	a[0] + x*p + -y*s,	a[1] + y*p + x*s,	];	}	function drawCurve(a, b, c){	if(opts.rect){	ctx.moveTo(a[0], a[1]);	ctx.quadraticCurveTo(b[0], b[1], c[0], c[1]);	}else{	ctx.moveTo(a[0], a[1]);	ctx.lineTo(b[0], b[1]);	ctx.lineTo(c[0], c[1]);	}	}	function drawIt(a, b, limit){	if(--limit < 0)	return;	let s = opts.s;	let m = lerp2(a, b, 0.5, 0);	let c = lerp2(a, b, 0.5-opts.s2, s);	let d = lerp2(a, b, 0.5-opts.s2, -s);	let e = lerp2(a, b, 0.5+opts.s2, s);	let f = lerp2(a, b, 0.5+opts.s2, -s);	a = lerp2(c, d, 0.5, -opts.s3);	b = lerp2(e, f, 0.5, opts.s3);	ctx.beginPath();	drawCurve(c,a,d);	drawCurve(d,m,c);	drawCurve(e,b,f);	drawCurve(f,m,e);	drawCurve(c,m,e);	drawCurve(d,m,f);	ctx.stroke();	drawIt(c,d, limit);	drawIt(e,f, limit);	}	function loop(){	ctx.clearRect(0,0, w,h);	drawIt([0, h/2], [w, h/2], opts.limit);	for(var i=0; i<gui.__controllers.length && opts.random; ++i){	var t = gui.__controllers[i];	if(!t.random)	continue;	t.setValue( opts[t.property]*(1-opts.speed) + t.newValue*opts.speed );	}	requestAnimationFrame(loop);	}	function random(){	for(var i=0; i<gui.__controllers.length; ++i){	var t = gui.__controllers[i];	if(!t.random)	continue;	if( t.oldValue === undefined )	t.oldValue = opts[t.property];	t.newValue = (t.__max-t.__min) * Math.random() + t.__min;	}	}	setInterval(random, 1000);	random();	loop();
}, false);
Curved fractal - Script Codes
Curved fractal - Script Codes
Home Page Home
Developer Findoff
Username findoff
Uploaded October 03, 2022
Rating 3.5
Size 2,430 Kb
Views 24,288
Do you need developer help for Curved fractal?

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!

Findoff (findoff) 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!