-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_line.html
42 lines (29 loc) · 1.04 KB
/
draw_line.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
<!DOCTYPE html>
<html>
<head><title>Draw line</title>
<script type="text/javascript">
function init() { try {
var canvas = document.getElementById('canvas');
var context_2d = canvas.getContext('2d');
context_2d.beginPath();
context_2d.lineWidth = '10';
context_2d.strokeStyle = '#0000ff';
context_2d.moveTo(20 , 20);
context_2d.lineTo(860,560);
context_2d.stroke();
context_2d.beginPath();
context_2d.lineCap = 'round';
context_2d.lineWidth = '10';
context_2d.strokeStyle = '#ff9900';
context_2d.moveTo(20 ,560);
context_2d.lineTo(860, 20);
context_2d.stroke();
} catch(e) {alert (e)} }
</script>
</head>
<body onload='init();'>
<canvas id ='canvas'
width='900' height='600'
style ='width:900px;height:600px;border:solid 1px black;margin-left:-450px;margin-top:-300px;left:50%;position:fixed;top:50%' ></canvas>
</body>
</html>