UNPKG

1.47 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var utils = require('@pixi/utils');
6var extensions = require('@pixi/extensions');
7
8class BackgroundSystem {
9 constructor() {
10 this.clearBeforeRender = true;
11 this._backgroundColor = 0;
12 this._backgroundColorRgba = [0, 0, 0, 1];
13 this._backgroundColorString = "#000000";
14 this.color = this._backgroundColor;
15 this.alpha = 1;
16 }
17 init(options) {
18 this.clearBeforeRender = options.clearBeforeRender;
19 if (options.color) {
20 this.color = typeof options.color === "string" ? utils.string2hex(options.color) : options.color;
21 }
22 this.alpha = options.alpha;
23 }
24 get color() {
25 return this._backgroundColor;
26 }
27 set color(value) {
28 this._backgroundColor = value;
29 this._backgroundColorString = utils.hex2string(value);
30 utils.hex2rgb(value, this._backgroundColorRgba);
31 }
32 get alpha() {
33 return this._backgroundColorRgba[3];
34 }
35 set alpha(value) {
36 this._backgroundColorRgba[3] = value;
37 }
38 get colorRgba() {
39 return this._backgroundColorRgba;
40 }
41 get colorString() {
42 return this._backgroundColorString;
43 }
44 destroy() {
45 }
46}
47BackgroundSystem.extension = {
48 type: [
49 extensions.ExtensionType.RendererSystem,
50 extensions.ExtensionType.CanvasRendererSystem
51 ],
52 name: "background"
53};
54extensions.extensions.add(BackgroundSystem);
55
56exports.BackgroundSystem = BackgroundSystem;
57//# sourceMappingURL=BackgroundSystem.js.map