-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
94 lines (74 loc) · 2.53 KB
/
index.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE HTML>
<head>
<title>smoky video controlled by hand</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="styleSheet.css" rel="stylesheet" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/ml5.min.js" type="text/javascript"></script>
<script src="smoke.js"></script>
</head>
<button id = start-button>Play</button>
<div class="container">
<canvas class="canvas" id="canvas" ></canvas>
<div id="top" class="top">
<video class="video" id="nature" controls>
<source src="video-short.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
<!-- <iframe class="video" id="nature" src="https://www.youtube.com/embed/BgRwb_qv1KY" frameborder="0" allow="accelerometer; controls; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
</div>
</div>
<script>
var flag = 0;
const startBtn = document.getElementById("start-button");
startBtn.addEventListener('click', start);
function start(){
flag = 1;
nature.play();
startBtn.style.visibility = "hidden";
console.log("success");
}
canvas = document.getElementById('canvas')
ctx = canvas.getContext('2d')
v = document.getElementById('nature');
canvas.width = innerWidth;
canvas.height = innerHeight;
//console.log(canvas.width);
var party = smokemachine(ctx, [255, 255, 255])
party.start() // start animating
party.setPreDrawCallback(function(dt){
party.addSmoke(innerWidth*Math.random(), innerHeight, .5)
canvas.width = innerWidth
canvas.height = innerHeight
})
// party.addsmoke(innerWidth/2, innerHeight, 100)
// onclick=e => {
// console.log(e)
// party.step()
// }
onmousemove = function (e){
// var xD = e.clientX;
// var yD = e.clientY;
// party.fleeParticles(xD,yD)
var x = Math.random()*canvas.width
var y = Math.random()*canvas.height
//console.log("move")
//var y = e.clientY+
var n = .5
var t = Math.floor(Math.random() * 200) + 1000 // start time
party.addsmoke(x, y, n, t)
}
/*onmousemove = function (e) {
//var x = e.clientX+Math.random()*canvas.width
var x = Math.random()*canvas.width
var y = Math.random()*canvas.height
console.log(x)
console.log(y)
//var y = e.clientY+
var n = .5
var t = Math.floor(Math.random() * 200) + 1000 // start time
party.addsmoke(x, y, n, t)
}*/
</script>
<script src="sketch.js"></script>