dygraph-dev --> dist/dygraph.js
[dygraphs.git] / tests / dashed-canvas.html
CommitLineData
fb63bf1b
DV
1<html>
2<head>
e8c70e4e 3 <script src="../src/polyfills/dashed-canvas.js"></script>
fb63bf1b
DV
4</head>
5<body>
6<p>You should see solid black and blue lines with a dashed red line in between
7them:</p>
8<canvas id=cnv width=640 height=480></canvas>
9
10<p>You should see a solid black line:</p>
11<canvas id=cnv2 width=640 height=100></canvas>
12
13<script type="text/javascript">
14ctx = document.getElementById("cnv").getContext("2d");
15ctx2 = document.getElementById("cnv2").getContext("2d");
16
17// Draw a line segment -- should be perfectly normal.
18ctx.lineWidth = 2;
19ctx.save();
20ctx.beginPath();
21ctx.moveTo(80, 50);
22ctx.lineTo(280, 400);
23ctx.moveTo(330, 400);
24ctx.lineTo(580, 200);
25ctx.stroke();
26
27// Draw a dashed line segment.
e8c70e4e
DV
28// ctx.installPattern([10, 10]);
29ctx.setLineDash([10, 10]);
fb63bf1b
DV
30ctx.strokeStyle = 'red';
31ctx.beginPath();
32ctx.moveTo(100, 50);
33ctx.lineTo(300, 400);
34ctx.lineTo(300, 450);
35ctx.moveTo(350, 450);
36ctx.lineTo(350, 400);
37ctx.lineTo(600, 200);
38ctx.stroke();
39
40// An unrelated canvas should not be aware of the pattern.
41ctx2.beginPath();
42ctx2.moveTo(100, 50);
43ctx2.lineTo(600, 50);
44ctx2.stroke();
45
e8c70e4e
DV
46// ctx.uninstallPattern();
47ctx.setLineDash([]);
fb63bf1b
DV
48
49// Now that we've uninstalled the pattern, should be normal again.
50ctx.strokeStyle = 'blue';
51ctx.beginPath();
52ctx.moveTo(120, 50);
53ctx.lineTo(320, 400);
54ctx.moveTo(370, 400);
55ctx.lineTo(620, 200);
56ctx.stroke();
57
58ctx.restore();
59</script>
60</body>
61</html>