1// This file is required by the index.html file and will
2// be executed in the renderer process for that window.
3// No Node.js APIs are available in this process because
4// `nodeIntegration` is turned off. Use `preload.js` to
5// selectively enable features needed in the rendering
6// process.
7
8class Renderer {
9  constructor() {
10    let c1 = document.getElementById('my_canvas_ipmi');
11    let c2 = document.getElementById('my_canvas_dbus');
12    let c3 = document.getElementById('my_canvas_boost_asio_handler');
13    this.canvas1 = c1;
14    this.canvas2 = c2;
15    this.canvas3 = c3;
16    this.width1 = c1.width; this.height1 = c1.height;
17    this.width2 = c2.width; this.height2 = c2.height;
18    this.width3 = c3.width; this.height3 = c3.height;
19    this.ctx1 = this.canvas1.getContext('2d');
20    this.ctx2 = this.canvas2.getContext('2d');
21    this.ctx3 = this.canvas3.getContext('2d');
22    this.frame_count = 0;
23    this.addBindings();
24    this.addListeners();
25    this.update();
26    this.run();
27  }
28
29  addBindings() {
30    this.update = this.update.bind(this);
31    this.run = this.run.bind(this);
32  }
33
34  addListeners() {
35    window.addEventListener('resize', this.update);
36  }
37
38  update() {
39    console.log('update, ' + window.innerWidth + ' x ' + window.innerHeight);
40    if (false) {
41      this.width1 = window.innerWidth;
42      this.height1 = window.innerHeight;
43      this.canvas1.width = this.width1;
44      this.canvas1.height = this.height1;
45    }
46  }
47
48  run() {
49    draw_timeline(this.ctx1);
50    draw_timeline_dbus(this.ctx2);
51    draw_timeline_boost_asio_handler(this.ctx3);
52    window.requestAnimationFrame(this.run);
53  }
54}
55
56g_renderer = new Renderer();