-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
64 lines (56 loc) · 1.3 KB
/
sketch.js
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
var myRec = new p5.SpeechRec(); // new P5.SpeechRec object
myRec.continuous = true; // do continuous recognition
var flag = 0;
function setup()
{
noCanvas();
myRec.onResult = showResult;
myRec.start(); // start recoginising speech
}
function showResult()
{
if(myRec.resultValue)
{
text_color();
reveal();
text_size();
scroll_screen();
p1.insertAdjacentHTML('beforeend', myRec.resultString + " ");
}
}
function text_color()
{
if ((" "+myRec.resultString+" ").search(" color ")!=-1)
{
document.getElementById("p1").style.color = "red";
}
}
function reveal()
{
if ((" "+myRec.resultString+" ").search(" reveal ")!=-1)
{
document.getElementById('p2').className = "show";
}
}
function text_size()
{
var i = (" "+myRec.resultString+" ").search(" size ")
if (i!=-1)
{
var n = (" "+myRec.resultString+" ").substring(i+6,(" "+myRec.resultString+" ").indexOf(" ",i+6) )
if (!isNaN(n))
{
document.getElementById("p1").style.fontSize = n;
}
}
}
function scroll_screen()
{
$(document).ready(function()
{
if ((" "+myRec.resultString+" ").search(" scroll ")!=-1)
{
$("html, body").animate({scrollTop: 5000}, 1500);
}
});
}