File: svg-arc.html

package info (click to toggle)
node-zrender 5.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,544 kB
  • sloc: javascript: 1,259; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,954 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Image</title>
    <script src="./lib/config.js"></script>
    <script src="../dist/zrender.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
    <div id="main" style="width:1000px;height:900px;"></div>

    <script type="text/javascript">

    var zr = zrender.init(document.getElementById('main'), {
        renderer: window.__ZRENDER__DEFAULT__RENDERER__ || 'svg'
    });

    for (var i = 0; i < 16; ++i) {
        var s = Math.PI / 4 * i;
        for (var j = 0; j < 16; ++j) {
            var e = Math.PI / 4 * j;
            var arc = new zrender.Arc({
                shape: {
                    cx: 50 + 50 * i,
                    cy: 50 + 50 * j,
                    r: 20
                },
                style: {
                    stroke: '#aaa',
                    fill: '#fff'
                }
            });
            zr.add(arc);
            var arc = new zrender.Arc({
                shape: {
                    cx: 50 + 50 * i,
                    cy: 50 + 50 * j,
                    r: 20,
                    startAngle: s,
                    endAngle: e,
                    clockwise: true
                },
                style: {
                    stroke: '#f00',
                    fill: 'rgba(255, 255, 0, 0.3)'
                }
            });
            zr.add(arc);

            const PIChar = String.fromCharCode(0x03C0);

            var text = new zrender.Text({
                style: {
                    // align: 'center',
                    // verticalAlign: 'center',
                    // text: `${i / 4}${PIChar}\n${j / 4}${PIChar}`,
                    text: `${i},${j}`,
                    fontSize: 12
                },
                position: [40 + 50 * i, 40 + 50 * j]
            });
            zr.add(text);
        }
    }
    </script>

</body>
</html>