-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_page_2.html
97 lines (81 loc) · 3.52 KB
/
test_page_2.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
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Interactive SVGs</title>
<link rel="stylesheet" type="text/css" href="interactiveSVG.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script type="text/javascript" src="interactiveSVG.js"></script>
<style type="text/css">
.svg-wrapper {
display: inline-block;
}
</style>
</head>
<body>
<h1>Test page</h1>
<p>This page contains multiple inline SVGs to make sure they don't interact with one another.</p>
<p>Here is the first</p>
<div id="svg-1" class="svg-wrapper"></div>
<div id="svg-2" class="svg-wrapper"></div>
<div id="svg-3" class="svg-wrapper"></div>
<div id="svg-4" class="svg-wrapper"></div>
<div id="svg-5" class="svg-wrapper"></div>
<script type="text/javascript">
// Point example
(function() {
var svg = InteractiveSVG.create('svg-1', 200, 200);
svg.addPoint({ x: 50, y: 50 });
svg.addPoint(100, 80);
svg.addStaticPoint(100, 120);
svg.addPoint({ x: 150, y: 50, static: true });
svg.addPoint({ x: 50, y: 150, r: 10 });
svg.addPoint({ x: 150, y: 150, class: 'controllable-point' });
})();
// Linked attributes example
(function() {
var svg = InteractiveSVG.create('svg-2', 200, 200);
var A = svg.addPoint(100, 180);
var B = svg.addPoint(10, 100);
var C = svg.addPoint(100, 100);
svg.linkAttributes(A, 'x', C, 'x');
svg.linkAttributes(B, 'y', C, 'y');
})();
// Line example
(function() {
var svg = InteractiveSVG.create('svg-3', 200, 200);
var A = svg.addPoint({ x: 40, y: 75 });
var B = svg.addPoint({ x: 160, y: 75 });
svg.addLine({p1: A, p2: B});
svg.addLine({p1: A, p2: {x: 40, y: 160}});
svg.addLine({x1: 160, y1: 160, p2: B});
svg.addLine({x1: 30, y1: 175, x2: 170, y2: 175});
svg.addPoint({ label: 'C', x: 100, y: 25 });
svg.addLine([A, 'C', B])
})();
// Text example
(function() {
var svg = InteractiveSVG.create('svg-4', 200, 200);
var P = svg.addPoint({ x: 100, y: 40 });
var txt = svg.addText({ x: 100, y: 20, value: "100" });
svg.linkAttributes(txt, 'value', P, 'x');
var txt2 = svg.addText({ x: 100, y: 80, draggable: true, value: "Draggable" });
var txt3 = svg.addText({ x: 100, y: 120, scrubber: true, value: 5 });
var txt4 = svg.addText({ x: 100, y: 150, scrubber: true, value: 0, scrubberScale: 0.1 });
P = svg.addPoint({ x: 100, y: 160 });
svg.linkAttributes(txt3, 'value', P, 'x');
svg.linkAttributes(txt4, 'value', P, 'x');
})();
// Tspan example
(function() {
var svg = InteractiveSVG.create('svg-5', 200, 200);
var txt = svg.addText({ x: 10, y: 20, value: "Point: " });
var xCoord = txt.addChild({scrubber: true, value: 5 });
txt.addChild({ value: ", " });
var yCoord = txt.addChild({scrubber: true, value: 20 });
var P = svg.addPoint({ x: 100, y: 160 });
svg.linkAttributes(xCoord, 'value', P, 'x');
svg.linkAttributes(yCoord, 'value', P, 'y');
})();
</script>
</body>
</html>