File: clipping.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 (66 lines) | stat: -rw-r--r-- 1,635 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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Clipping</title>
    <script src="../dist/zrender.js"></script>
</head>
<body>
    <div id="main" style="width:1000px;height:600px;"></div>
    <script type="text/javascript">
        // 初始化zrender
        var zr = zrender.init(document.getElementById('main'));

        var g1 = new zrender.Group();
        var g2 = new zrender.Group();
        g1.add(g2);
        zr.add(g1);

        var circle = new zrender.Circle({
            shape: {
                r: 0,
                cx: 0,
                cy: 0
            },
            position: [200, 200]
        });

        g2.setClipPath(circle);

        var rect = new zrender.Rect({
            shape: {
                width: 500,
                height: 300,
                x: -250,
                y: -20
            },
            position: [200, 150]
        });
        g1.setClipPath(rect);

        for (var i = 0; i < 50; i++) {
            for( var j = 0; j < 50; j++){
                var image = new zrender.Image({
                    position: [i * 50, j * 50],
                    scale: [1, 1],
                    style: {
                        x: 0,
                        y: 0,
                        image: 'asset/test.png',
                        width: 50,
                        height: 50
                    },
                    draggable: true
                });
                g2.add(image);
            }
        }

        circle.animateShape()
            .when(1000, {
                r: 300
            })
            .start();
    </script>
</body>
</html>