Randomly generated canvas clouds

Developer
Size
2,028 Kb
Views
10,120

How do I make an randomly generated canvas clouds?

Randomly generated quadratic curves to create "clouds".. What is a randomly generated canvas clouds? How do you make a randomly generated canvas clouds? This script and codes were developed by Dave DeHaan on 04 January 2023, Wednesday.

Randomly generated canvas clouds Previews

Randomly generated canvas clouds - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Randomly generated canvas clouds</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <center>	<canvas id="canvas" width="1000" height="400">	</canvas>
</center> <script src="js/index.js"></script>
</body>
</html>

Randomly generated canvas clouds - Script Codes CSS Codes

body {	padding: 0px;	margin: 0px;	background: #ecf0f1;
}
#canvas {	background: #3498db;	width: 100%;	height: 400px;
}

Randomly generated canvas clouds - Script Codes JS Codes

/* * Start Config Vars */
var yPosMax = 175;
var yPosMin = 125;
var yPosStart = 150;
var xPosStart = -50;
var yPosChangeMultiplier = 60;
var xPosChangeMin = 125;
var xPosChangeMultiplier = 25;
var yControlMultiplier = 20;
var yControlMin = 40;
/* * End Config Vars */
canvas = document.getElementById('canvas');
context = canvas.getContext('2d');
context.fillStyle = '#ecf0f1';
var xPos = xPosStart;
var yPos = yPosStart;
context.beginPath();
context.moveTo(xPos, yPos);
while (xPos < canvas.width) { lastX = xPos;	xPos += Math.floor(Math.random() * xPosChangeMultiplier + xPosChangeMin);	yPos += Math.floor(Math.random() * yPosChangeMultiplier - yPosChangeMultiplier/2);	while (yPos < yPosMin) {	yPos += Math.floor(Math.random() * yPosChangeMultiplier/2);	}	while (yPos > yPosMax) {	yPos -= Math.floor(Math.random() * yPosChangeMultiplier/2);	} controlX = (lastX + xPos)/2; controlY = yPos-Math.floor(Math.random() * yControlMultiplier + yControlMin);	context.quadraticCurveTo(controlX,controlY,xPos,yPos);
}
context.lineTo(canvas.width,yPos);
context.lineTo(canvas.width,canvas.height);
context.lineTo(0,canvas.height);
context.fill();
Randomly generated canvas clouds - Script Codes
Randomly generated canvas clouds - Script Codes
Home Page Home
Developer Dave DeHaan
Username davedehaan
Uploaded January 04, 2023
Rating 3.5
Size 2,028 Kb
Views 10,120
Do you need developer help for Randomly generated canvas clouds?

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!

Dave DeHaan (davedehaan) Script Codes
Create amazing blog posts 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!