-
Notifications
You must be signed in to change notification settings - Fork 46
/
sample_instance.html
51 lines (38 loc) · 920 Bytes
/
sample_instance.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
<div id="canvasHolder" style="border:1px solid black;width:600px;height:500px"></div>
<script src="lib/p5.js"></script>
<script src="lib/scenemanager.js"></script>
<script>
var program = new p5(Program, "canvasHolder");
// Use p5.js in "instance mode"
function Program(p)
{
p.setup = function()
{
p.createCanvas(600, 500);
var mgr = new SceneManager(p);
mgr.wire();
mgr.showScene( LineAnimation );
}
}
// SceneManager can be used also when p5.js is used in "instance mode"
function LineAnimation(p)
{
this.y = 0;
this.setup = function()
{
p.background("teal");
}
this.draw = function()
{
p.background("teal");
p.line(0, this.y, p.width, this.y);
this.y++;
if ( this.y > p.height )
this.y = 0;
}
this.mousePressed = function()
{
console.log("Mouse Pressed");
}
}
</script>