-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudy_blue_perlin_sky.html
53 lines (43 loc) · 1.34 KB
/
cloudy_blue_perlin_sky.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html >
<!--
http://proceduralgraphics.blogspot.com
By Dave Lawrence on 24/4/2010
Draws a cloudy blue sky with Perlin noise
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
html,body { width:100%; height:100%; margin:0; padding:0; overflow:hidden; }
</style>
<title></title>
<script type="text/javascript" src="util.js"></script>
<script type="text/javascript" src="drawing.js"></script>
<script type="text/javascript" src="perlin.js"></script>
<script type="text/javascript">
var width = window.innerWidth;
var height = window.innerHeight;
var ctx;
var clouds;
// write out canvas as we have to put width/height inline in the HTML, CSS will just scale pixels
document.write('<canvas id="canvas" width=' + width + ' height=' + height + '></canvas>');
function setup() {
ctx = document.getElementById("canvas").getContext("2d");
clouds = newCanvas(width, height);
perlin_noise(clouds, whiteClouds);
draw();
}
function whiteClouds() {
return [255, 255, 255, irand(255)];
}
function draw() {
// Blue Sky
ctx.fillStyle = "#0000FF";
ctx.fillRect(0,0,width,height);
// Clouds
ctx.drawImage(clouds, 0, 0);
}
</script>
</head>
<body onload="setup()">
</body>
</html>