/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<html>
	<body>
	
	<table>
		<tr>
			<td>
				<canvas id='a' width='600' height='450' style='border:2px solid black;'>
				</canvas>
			</td>
			<td>
				<div style="border:2px solid black;background-color:#fed;width:300;height:450;">
					<div id="infobox" style="padding:4px;">
					Change values in form to update curve and information box.
					</div>
				</div>
			</td>			
		</tr>
	</table>	

	<form>
	
	Function: 
	<select id="function" name="function" onchange="dataentry(this.options[this.selectedIndex].value,this.options[this.selectedIndex].label);">
			<option value="Func">Linear</option>
			<option value="Func">Step</option>
			<option value="Func">Smoothstep</option>
	</select>			
	<br>
	

			
	</form>		
	<br>
	
	
	
	</div>

	<script lang='Javascript'>
		
		var mx=100,my=100,clickstate=0;

		function ev_mouseup(ev)
		{
				clickstate=0;
		}
		
		function ev_mousedown(ev)
		{
				clickstate=1;
		}
		
		function ev_mousemove (ev) 
		{
				if(clickstate==1){
					  if (ev.layerX||ev.layerX==0) { // Firefox
						    mx=ev.layerX-acanvas.offsetLeft;
						    my=ev.layerY-acanvas.offsetTop;
					  } else if (ev.offsetX || ev.offsetX == 0) { // Opera
						    mx=ev.offsetX-acanvas.offsetLeft;
						    my=ev.offsetY-acanvas.offsetTop;
					  }
				}		
		}

		var acanvas=document.getElementById('a');
		var context=acanvas.getContext("2d");		

		// Mouse Events
		acanvas.addEventListener('mousemove', ev_mousemove, false);
		acanvas.addEventListener('mouseup', ev_mouseup, false);
		acanvas.addEventListener('mousedown', ev_mousedown, false);

		// Touch Events
		acanvas.addEventListener('touchstart', ev_touchstart, false);
		acanvas.addEventListener('touchend', ev_touchend, false);
		acanvas.addEventListener('touchmove', ev_touchmove, false);

/*

Single Touch Works!

Multi Touch Enabled:

for (var i = 0; i < event.touches.length; i++) {
    var touch = event.touches[i];
    ctx.beginPath();
    ctx.arc(touch.pageX, touch.pageY, 20, 0, 2*Math.PI, true);
    ctx.fill();
    ctx.stroke();
}


*/

		// Touch start event
		function ev_touchstart(event){  
    		event.preventDefault();  
     		var numtouch = event.touches.length;  
     		clickstate=1;  
		};  

		// Touch end event
		function ev_touchend(event){  
    		event.preventDefault();  
     		var numtouch = event.touches.length;  
				clickstate=0;
		};  
		
		// Touch move event
		function ev_touchmove(event){  
    		event.preventDefault();  
     		var numtouch = event.touches.length;  

				targetEvent =  event.touches.item(0);
//				mx = targetEvent.clientX;
//				my = targetEvent.clientY;

				mx = targetEvent.pageX;
				my = targetEvent.pageY;
		};  
		
		setTimeout("foo();",20);
		

		function foo()
		{
				context.clearRect(0,0,600,600);
				
				context.strokeStyle = '#000';
				context.lineWidth   = 1.5;
				if(clickstate==1){
						context.beginPath();
						context.moveTo(0,0);
						context.lineTo(mx,my);
						context.stroke();	
				}

				setTimeout("foo();",100);
				
	  }
	  
					
	</script>

	</body>
</html>