-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.html
65 lines (57 loc) · 1.7 KB
/
container.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://pixijs.download/release/pixi.js"></script>
</head>
<body>
</body>
<script>
let app = new PIXI.Application({
width: 1240,
height: 760
});
document.body.appendChild(app.view);
const frame = new PIXI.Graphics();
frame.beginFill(0xffffff);
frame.drawRect(0, 0, 200, 200);
frame.endFill();
// frame.beginFill(0x666666);
// frame.lineStyle({
// color: 0xffffff,
// width: 4,
// alignment: 0
// });
// frame.drawRect(100, 100, 208, 208);
// frame.position.set(320 - 104, 180 - 104);
app.stage.addChild(frame);
const mask = new PIXI.Graphics();
mask.beginFill(0x666666);
mask.drawRect(0, 0, 200, 200);
mask.endFill();
const maskContainer = new PIXI.Container();
maskContainer.mask = mask;
maskContainer.addChild(mask);
// maskContainer.position.set(4, 4);
frame.addChild(maskContainer);
const text = new PIXI.Text(
'This text will scroll up and be masked, so you can see how masking works. Lorem ipsum and all that.\n\n' +
'You can put anything in the container and it will be masked!', {
fontSize: 24,
fill: 0x1010ff,
wordWrap: true,
wordWrapWidth: 180
}
);
text.x = 10;
maskContainer.addChild(text);
let elapsed = 0;
app.ticker.add((delta) => {
elapsed += delta;
text.y = 10 + -100 + Math.cos(elapsed / 50) * 100;
});
</script>
</html>