-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
115 lines (115 loc) · 3.85 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!doctype html>
<html lang="en" style="width:100%;height:100%;"><head><title>faking interaction</title>
<style>
body,html{touch-action:none;}
</style>
<script>
svgNS="http://www.w3.org/2000/svg";
drawing=false;
stretching=false;
x1=0;
y1=0;
x2=0;
y2=0;
alert("How-to-use:\n===========\n1: Put finger down\n 2: Say 'i'\n3: Move finger a lot\n 4: Say 'love'\n5: Lift finger\n 6: Say 'graphs'\n7: Click outside your creation");
function drawTriple_listenForA(ev){
x1=ev.x;
y1=ev.y;
var translate="translate("+x1+","+y1+")";
var triple=document.getElementById("triple");
triple.setAttribute("transform",translate);
triple.setAttribute("visibility","visible");
drawing=true;
startRecording("A");
document.addEventListener('pointerdown', completeB, false);
}
function stretchTriple_listenForR(ev){
if (drawing){
if (!stretching){
stopRecording("A")
startRecording("R")
stretching=true;
}else{
x2=ev.x-x1;
y2=ev.y-y1;
var R=document.getElementById("R");
R.setAttribute("x2",x2);
R.setAttribute("y2",y2);
var B=document.getElementById("B");
B.setAttribute("cx",x2);
B.setAttribute("cy",y2);
}
}
}
function listenForB(ev){
stopRecording("R");
drawing=false;
startRecording("B");
}
function completeB(ev){
stopRecording("B");
document.removeEventListener('keydown', completeB, false);
}
// ...
function startRecording(elmId){
// TODO future start audio recording on audiofragment elmId, see https://developers.google.com/web/fundamentals/media/recording-audio
document.getElementById(elmId)
.setAttribute("stroke","red");
}
function stopRecording(elmId){
// TODO future stop audio recording on audiofragment elmId
elm=document.getElementById(elmId);
elm.setAttribute("stroke","black");
elm.setAttribute("fill","none");
if (elmId=="R"){
document.getElementById("R").setAttribute("marker-end","url(#blackArrow)");
}
startShowingResults(elmId);
}
function startShowingResults(elmId){
if (elmId=="A"){
tempA=document.getElementById("textA")
tempA.setAttribute("visibility","visible");
document.removeEventListener('pointerdown',drawTriple_listenForA, false);
}
if (elmId=="R"){
tempR=document.getElementById("textR")
tempR.setAttribute("visibility","visible");
tempR.setAttribute("x",x2/2);
tempR.setAttribute("y",y2/2);
document.removeEventListener('pointermove',stretchTriple_listenForR,false);
}
if (elmId=="B"){
tempB=document.getElementById("textB")
tempB.setAttribute("visibility","visible");
tempB.setAttribute("x",x2);
tempB.setAttribute("y",y2);
document.removeEventListener('pointerup',listenForB,false);
}
}
// ...
document.addEventListener('pointerdown', drawTriple_listenForA, false);
document.addEventListener('pointermove', stretchTriple_listenForR, false);
document.addEventListener('pointerup', listenForB, false);
</script>
</head>
<body style="width:100%;height:100%;margin:0;"><svg width="100%" height="100%">
<defs>
<marker id="blackArrow" viewBox="0 0 10 10" refX="1" refY="5"
markerUnits="strokeWidth" markerWidth="4" markerHeight="3"
orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="black"/>
</marker>
<marker id="redArrow" viewBox="0 0 10 10" refX="1" refY="5"
markerUnits="strokeWidth" markerWidth="4" markerHeight="3"
orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="red"/>
</marker>
</defs><g id="triple" visibility="hidden" fill="grey" stroke="grey" stroke-width="10">
<circle id="B" r="100" />
<line id="R" marker-end="url(#redArrow)"/>
<circle id="A" r="100" /><g stroke-width="1" stroke="red" fill="red" font-size="200%">
<text id="textA" visibility="hidden" font-size="200%">i</text>
<text id="textR" visibility="hidden">❤️</text>
<text id="textB" visibility="hidden">graphs</text></g>
</g></svg></body></html>