7
<canvas id='a' width='600' height='450' style='border:2px solid black;'>
11
<div style="border:2px solid black;background-color:#fed;width:300;height:450;">
12
<div id="infobox" style="padding:4px;">
13
Change values in form to update curve and information box.
23
<select id="function" name="function" onchange="dataentry(this.options[this.selectedIndex].value,this.options[this.selectedIndex].label);">
24
<option value="Func">Linear</option>
25
<option value="Func">Step</option>
26
<option value="Func">Smoothstep</option>
39
<script lang='Javascript'>
41
var mx=100,my=100,clickstate=0;
43
function ev_mouseup(ev)
48
function ev_mousedown(ev)
53
function ev_mousemove (ev)
56
if (ev.layerX||ev.layerX==0) { // Firefox
57
mx=ev.layerX-acanvas.offsetLeft;
58
my=ev.layerY-acanvas.offsetTop;
59
} else if (ev.offsetX || ev.offsetX == 0) { // Opera
60
mx=ev.offsetX-acanvas.offsetLeft;
61
my=ev.offsetY-acanvas.offsetTop;
66
var acanvas=document.getElementById('a');
67
var context=acanvas.getContext("2d");
70
acanvas.addEventListener('mousemove', ev_mousemove, false);
71
acanvas.addEventListener('mouseup', ev_mouseup, false);
72
acanvas.addEventListener('mousedown', ev_mousedown, false);
75
acanvas.addEventListener('touchstart', ev_touchstart, false);
76
acanvas.addEventListener('touchend', ev_touchend, false);
77
acanvas.addEventListener('touchmove', ev_touchmove, false);
85
for (var i = 0; i < event.touches.length; i++) {
86
var touch = event.touches[i];
88
ctx.arc(touch.pageX, touch.pageY, 20, 0, 2*Math.PI, true);
97
function ev_touchstart(event){
98
event.preventDefault();
99
var numtouch = event.touches.length;
104
function ev_touchend(event){
105
event.preventDefault();
106
var numtouch = event.touches.length;
111
function ev_touchmove(event){
112
event.preventDefault();
113
var numtouch = event.touches.length;
115
targetEvent = event.touches.item(0);
116
// mx = targetEvent.clientX;
117
// my = targetEvent.clientY;
119
mx = targetEvent.pageX;
120
my = targetEvent.pageY;
123
setTimeout("foo();",20);
128
context.clearRect(0,0,600,600);
130
context.strokeStyle = '#000';
131
context.lineWidth = 1.5;
135
context.lineTo(mx,my);
139
setTimeout("foo();",100);