MCPcopy
hub / github.com/spritejs/spritejs / Node

Class Node

src/node/node.js:24–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22const _uniforms = Symbol('uniforms');
23
24export default class Node {
25 static Attr = Attr;
26
27 constructor(attrs = {}) {
28 this.attributes = new this.constructor.Attr(this);
29 this[_resolution] = {width: 300, height: 150};
30 Object.assign(this.attributes, attrs);
31 // if(Object.seal) {
32 // Object.seal(this.attributes);
33 // }
34 this[_animations] = new Set();
35 this[_eventListeners] = {};
36 this[_captureEventListeners] = {};
37 }
38
39 get ancestors() {
40 let parent = this.parent;
41 const ret = [];
42 while(parent) {
43 ret.push(parent);
44 parent = parent.parent;
45 }
46 return ret;
47 }
48
49 get animations() {
50 return this[_animations];
51 }
52
53 get filters() {
54 return this[_filters] || (this.parent && this.parent.filters);
55 }
56
57 get isVisible() {
58 return false;
59 }
60
61 get layer() {
62 if(this.parent) return this.parent.layer;
63 return null;
64 }
65
66 get localMatrix() {
67 const m = this.transformMatrix;
68 const {x, y} = this.attributes;
69 m[4] += x;
70 m[5] += y;
71 return m;
72 }
73
74 get opacity() {
75 let opacity = this.attributes.opacity;
76 if(this.parent && this.parent.opacity != null) {
77 opacity *= this.parent.opacity;
78 }
79 return opacity;
80 }
81

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected