• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

excaliburjs / Excalibur / 14804036802

02 May 2025 09:58PM UTC coverage: 5.927% (-83.4%) from 89.28%
14804036802

Pull #3404

github

web-flow
Merge 5c103d7f8 into 0f2ccaeb2
Pull Request #3404: feat: added Graph module to Math

234 of 8383 branches covered (2.79%)

229 of 246 new or added lines in 1 file covered. (93.09%)

13145 existing lines in 208 files now uncovered.

934 of 15759 relevant lines covered (5.93%)

4.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/engine/Graphics/Context/state-stack.ts
1
import { Color } from '../../Color';
2
import { RentalPool } from '../../Util/RentalPool';
3
import { ExcaliburGraphicsContextState } from './ExcaliburGraphicsContext';
4
import { Material } from './material';
5

6
export class ContextState implements ExcaliburGraphicsContextState {
UNCOV
7
  opacity: number = 1;
×
UNCOV
8
  z: number = 0;
×
UNCOV
9
  tint: Color | null | undefined = Color.White;
×
UNCOV
10
  material: Material | null | undefined = null;
×
11
}
12

13
export class StateStack {
UNCOV
14
  private _pool = new RentalPool<ContextState>(
×
UNCOV
15
    () => new ContextState(),
×
16
    (s) => {
UNCOV
17
      s.opacity = 1;
×
UNCOV
18
      s.z = 0;
×
UNCOV
19
      s.tint = Color.White;
×
UNCOV
20
      s.material = null;
×
UNCOV
21
      return s;
×
22
    },
23
    100
24
  );
UNCOV
25
  public current: ExcaliburGraphicsContextState = this._pool.rent(true);
×
UNCOV
26
  private _states: ExcaliburGraphicsContextState[] = [];
×
27

28
  private _cloneState(dest: ContextState) {
UNCOV
29
    dest.opacity = this.current.opacity;
×
UNCOV
30
    dest.z = this.current.z;
×
UNCOV
31
    dest.tint = this.current.tint?.clone();
×
UNCOV
32
    dest.material = this.current.material; // TODO is this going to cause problems when cloning
×
UNCOV
33
    return dest;
×
34
  }
35

36
  public save(): void {
UNCOV
37
    this._states.push(this.current);
×
UNCOV
38
    this.current = this._cloneState(this._pool.rent());
×
39
  }
40

41
  public restore(): void {
UNCOV
42
    this._pool.return(this.current);
×
UNCOV
43
    this.current = this._states.pop()!;
×
44
  }
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc