UNPKG

1.98 kBJavaScriptView Raw
1import { Color } from "@pixi/color";
2import { ExtensionType, extensions } from "@pixi/extensions";
3class BackgroundSystem {
4 constructor() {
5 this.clearBeforeRender = !0, this._backgroundColor = new Color(0), this.alpha = 1;
6 }
7 /**
8 * initiates the background system
9 * @param {PIXI.IRendererOptions} options - the options for the background colors
10 */
11 init(options) {
12 this.clearBeforeRender = options.clearBeforeRender;
13 const { backgroundColor, background, backgroundAlpha } = options, color = background ?? backgroundColor;
14 color !== void 0 && (this.color = color), this.alpha = backgroundAlpha;
15 }
16 /**
17 * The background color to fill if not transparent.
18 * @member {PIXI.ColorSource}
19 */
20 get color() {
21 return this._backgroundColor.value;
22 }
23 set color(value) {
24 this._backgroundColor.setValue(value);
25 }
26 /**
27 * The background color alpha. Setting this to 0 will make the canvas transparent.
28 * @member {number}
29 */
30 get alpha() {
31 return this._backgroundColor.alpha;
32 }
33 set alpha(value) {
34 this._backgroundColor.setAlpha(value);
35 }
36 /** The background color object. */
37 get backgroundColor() {
38 return this._backgroundColor;
39 }
40 destroy() {
41 }
42}
43BackgroundSystem.defaultOptions = {
44 /**
45 * {@link PIXI.IRendererOptions.backgroundAlpha}
46 * @default 1
47 * @memberof PIXI.settings.RENDER_OPTIONS
48 */
49 backgroundAlpha: 1,
50 /**
51 * {@link PIXI.IRendererOptions.backgroundColor}
52 * @default 0x000000
53 * @memberof PIXI.settings.RENDER_OPTIONS
54 */
55 backgroundColor: 0,
56 /**
57 * {@link PIXI.IRendererOptions.clearBeforeRender}
58 * @default true
59 * @memberof PIXI.settings.RENDER_OPTIONS
60 */
61 clearBeforeRender: !0
62}, /** @ignore */
63BackgroundSystem.extension = {
64 type: [
65 ExtensionType.RendererSystem,
66 ExtensionType.CanvasRendererSystem
67 ],
68 name: "background"
69};
70extensions.add(BackgroundSystem);
71export {
72 BackgroundSystem
73};
74//# sourceMappingURL=BackgroundSystem.mjs.map