1 | import { Color } from '@pixi/color';
|
2 | import { ExtensionType, extensions } from '@pixi/extensions';
|
3 |
|
4 | class BackgroundSystem {
|
5 | constructor() {
|
6 | this.clearBeforeRender = true;
|
7 | this._backgroundColor = new Color(0);
|
8 | this.alpha = 1;
|
9 | }
|
10 | init(options) {
|
11 | this.clearBeforeRender = options.clearBeforeRender;
|
12 | const { backgroundColor, background, backgroundAlpha } = options;
|
13 | const color = background ?? backgroundColor;
|
14 | if (color !== void 0) {
|
15 | this.color = color;
|
16 | }
|
17 | this.alpha = backgroundAlpha;
|
18 | }
|
19 | get color() {
|
20 | return this._backgroundColor.value;
|
21 | }
|
22 | set color(value) {
|
23 | this._backgroundColor.setValue(value);
|
24 | }
|
25 | get alpha() {
|
26 | return this._backgroundColor.alpha;
|
27 | }
|
28 | set alpha(value) {
|
29 | this._backgroundColor.setAlpha(value);
|
30 | }
|
31 | get backgroundColor() {
|
32 | return this._backgroundColor;
|
33 | }
|
34 | destroy() {
|
35 | }
|
36 | }
|
37 | BackgroundSystem.defaultOptions = {
|
38 | backgroundAlpha: 1,
|
39 | backgroundColor: 0,
|
40 | clearBeforeRender: true
|
41 | };
|
42 | BackgroundSystem.extension = {
|
43 | type: [
|
44 | ExtensionType.RendererSystem,
|
45 | ExtensionType.CanvasRendererSystem
|
46 | ],
|
47 | name: "background"
|
48 | };
|
49 | extensions.add(BackgroundSystem);
|
50 |
|
51 | export { BackgroundSystem };
|
52 |
|