Drawing clouds

Developer
Size
3,371 Kb
Views
24,288

How do I make an drawing clouds?

Or is it a wooly chameleon? . What is a drawing clouds? How do you make a drawing clouds? This script and codes were developed by PotatoDie on 15 September 2022, Thursday.

Drawing clouds Previews

Drawing clouds - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Drawing clouds</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="wrap"> <canvas id="paperCanvas"></canvas> <canvas id="trailCanvas"></canvas>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/paper.js/0.9.12/paper.js'></script> <script src="js/index.js"></script>
</body>
</html>

Drawing clouds - Script Codes CSS Codes

body { color:#fff; background: #000; text-align: center;
}
#wrap { width:1000px; height: 600px; max-width: 100%; position: relative; margin: 0 auto;
}
canvas { /*border: 1px solid white;*/ width:100%; position: absolute; left: 0; top: 0; cursor: pointer;
}

Drawing clouds - Script Codes JS Codes

/*	Aim planet on a constellation of 2 stars, one of which has a mass that changes with time (e.g. sine wave) */
var count = 0;
window.onload = function() {	// Get a reference to the canvas object	var canvas = document.getElementById('paperCanvas');	// Create an empty project and a view for the canvas:	paper.setup(canvas);	/*	This canvas is here just to make paperjs work. I draw onto another canvas.	Haven't solved aligning the 2 canvases (yet) when their size depends on screensize.	Better to find a replacement for paper: I just use it for doing vector math. */	initTrailCanvas();	buildUniverse();	paper.view.onFrame = update;	document.getElementById('trailCanvas').onclick = function() {	clearCanvas();	planet.position = new paper.Point ( {x: 200 + 100 * Math.random(), y: 300 + 100 * Math.random()})	}
}
// Close to the suns the force is enormous. Compensate it when closer than dprox
// Smaller dprox give mores detail in the drawing
// Use it too for bounce effects: too close than invert the force
var dprox = 22;
var suns =[];
var planet = {	position: new paper.Point({	x: 200,	y: 300	}),	speed: new paper.Point({	x: 0.0,	y: -.2	})
}
function buildUniverse() {	var color = new paper.Color(0.1,0,0);	var p = new paper.Path.Circle({center: {x:100, y:300}, radius: 6});	p.fillColor = color;	p.mass = 9e+12;	suns.push( p );	p = new paper.Path.Circle({center: {x:200, y:200}, radius: 6});	p.fillColor = color;	p.mass = 9e+12;	suns.push( p );	p = new paper.Path.Circle({center: {x:300, y:300}, radius: 6});	p.fillColor = color;	p.mass = 9e+12;	suns.push( p );	p = new paper.Path.Circle({center: {x:200, y:400}, radius: 6});	p.fillColor = color;	p.mass = 9e+12;	suns.push( p );
}
var G = 6.674e-11; // gravitational constant
update = function(event) {	// A line consists of many dots	var rv, d, n, a;	var iterations = 40;	/* * Update draws the next 'frame'. If you just draw 1 dot, to represent the position of the planet, * you don't have enough dots to create a fluent line. * Iterations is meant to do more calculations (and representations) than the rhytm of the * update function dictates. In effect you work more accurately (more samples). * Note that recalculating the speed, you divide by iterations. * * That's why iterations influences the graphic. More iterations, less 'error'. * * Many iterations may decrease the graphic quality (grunge). */	for ( var j = 0; j < iterations; j++ ){	a = new paper.Point(0,0);	count += .001;	for (var i = 0; i < suns.length; i++ ) {	// if ( i > 1 )	suns[i].position = suns[i].position.add([.16*(Math.sin(count)),.02*(Math.cos(count))]);	// pos.x += ;	rv = suns[i].position.subtract(planet.position);	d = rv.length;	n = rv.normalize();	if ( d < dprox ) {	n = n.multiply(Math.pow(d/dprox,2));	// n = n.multiply(-1); // bounce	}	m = suns[i].mass;	// if ( i == 1 ) {	//	var f = Math.sin(dt/1000)/2 + 0.5;	//	m *= f;	//	suns[i].opacity = f;	// }	// else if ( i == 3 ) {	//	var f = Math.cos(dt/1000)/2 + 0.5;	//	m *= f;	//	suns[i].opacity = f;	// }	a.x += n.x*(G*m)/(Math.pow(d,2));	a.y += n.y*(G*m)/(Math.pow(d,2));	}	planet.speed = planet.speed.add ( a.divide ( iterations ) );	planet.position = planet.position.add(planet.speed);	drawDot(planet.position, 4/(planet.speed.length+2), .04);	}
}
/*! * Canvas drawing functions for the trail */
var ctx;
function initTrailCanvas() { var canvas = document.getElementById('trailCanvas'); canvas.width = 1000; canvas.height = 600; ctx = canvas.getContext('2d'); ctx.fillStyle = "#fff";
}
function drawDot(p, r, ga) { ctx.globalAlpha = ga; ctx.beginPath(); ctx.arc(p.x, p.y,r,0,Math.PI*2,true); ctx.fill();
}
function clearCanvas() { ctx.clearRect(0, 0, 1000,600);
}
Drawing clouds - Script Codes
Drawing clouds - Script Codes
Home Page Home
Developer PotatoDie
Username potatoDie
Uploaded September 15, 2022
Rating 4
Size 3,371 Kb
Views 24,288
Do you need developer help for Drawing 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!

PotatoDie (potatoDie) Script Codes
Create amazing video scripts 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!