File: pattern.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 (79 lines) | stat: -rw-r--r-- 2,024 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
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Image</title>
    <script src="../dist/zrender.js"></script>
</head>
<body>
    <style>
        html, body, #main {
            width: 100%;
            height: 100%;
        }
    </style>
    <div id="main"></div>
    <script type="text/javascript">
        var zr = zrender.init(document.getElementById('main'), {
            renderer: 'svg'
        });

        const circle = new zrender.Circle({
            shape: {
                r: 200,
                cx: 400,
                cy: 400
            },
            style: {
                fill: {
                    image: 'asset/test.png'
                }
            },
            textContent: new zrender.Text({
                style: {
                    text: '图片路径',
                    textFill: 'white',
                    fontSize: 40
                }
            }),
            textConfig: {
                position: 'inside'
            }
        });
        zr.add(circle);


        const img = new Image();
        img.onload = function () {
            const circle = new zrender.Circle({
                shape: {
                    r: 200,
                    cx: 800,
                    cy: 400
                },
                style: {
                    fill: {
                        image: img
                    }
                },
                textContent: new zrender.Text({
                    style: {
                        text: '图片对象',
                        textFill: 'white',
                        fontSize: 40
                    }
                }),
                textConfig: {
                    position: 'inside'
                }
            });
            zr.add(circle);
        }
        img.src = 'asset/test.png';

        zr.add(circle);
    </script>
</body>
</html>