-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample01.html
60 lines (47 loc) · 1.19 KB
/
example01.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="scripts/Physical.base.js"></script>
<script type="text/javascript" src="scripts/Glimmer.core.js"></script>
</head>
<body>
<script type="text/javascript">
var canvas = document.createElement('canvas');
canvas.style.cssText = 'border:1px solid #000';
var ctx = canvas.getContext('2d');
function draw(ctx){
var seg1 = Segment.create(10, 30, 240, 80);
var seg2 = Segment.create(5, 140, 260, 10);
var seg3 = Segment.create(70, 5, 20, 150);
var c1 = seg1.cross(seg2);
var c2 = seg1.cross(seg3);
var c3 = seg2.cross(seg3);
var a = Math.PI / 6;
var a = Angle.degree(15);
drawSegment(ctx, seg1);
drawSegment(ctx, seg2);
drawSegment(ctx, seg3);
drawPoint(ctx, c1);
drawPoint(ctx, c2);
drawPoint(ctx, c3);
}
function drawPoint(ctx, p){
if(!p) return;
ctx.beginPath();
ctx.rect(p.x - 2.5, p.y - 2.5, 5, 5);
ctx.stroke();
}
function drawSegment(ctx, seg){
ctx.beginPath();
ctx.moveTo(seg.o.x, seg.o.y);
ctx.lineTo(seg.e.x, seg.e.y);
ctx.stroke();
}
window.onload = function(){
document.body.appendChild(canvas);
draw(ctx);
}
</script>
</body>
</html>