Browse Source

Fixes in initialize-canvas.js. Updated tests

Dmitriy Slipak 4 years ago
parent
commit
77aea7e9ec
2 changed files with 7 additions and 4 deletions
  1. 4 2
      audiogram/initialize-canvas.js
  2. 3 2
      test/frame-test.js

+ 4 - 2
audiogram/initialize-canvas.js View File

3
     Canvas = require("canvas"),
3
     Canvas = require("canvas"),
4
     getRenderer = require("../renderer/");
4
     getRenderer = require("../renderer/");
5
 
5
 
6
+const { Image } = require("canvas");
7
+
6
 function initializeCanvas(theme, cb) {
8
 function initializeCanvas(theme, cb) {
7
 
9
 
8
   // Fonts pre-registered in bin/worker
10
   // Fonts pre-registered in bin/worker
19
       return cb(err);
21
       return cb(err);
20
     }
22
     }
21
 
23
 
22
-    const canvas = Canvas.createCanvas();
23
-    var bg = canvas.Image;
24
+    const bg = new Image();
24
     bg.src = raw;
25
     bg.src = raw;
26
+    
25
     renderer.backgroundImage(bg);
27
     renderer.backgroundImage(bg);
26
 
28
 
27
     return cb(null, renderer);
29
     return cb(null, renderer);

+ 3 - 2
test/frame-test.js View File

6
     initializeCanvas = require("../audiogram/initialize-canvas.js"),
6
     initializeCanvas = require("../audiogram/initialize-canvas.js"),
7
     drawFrames = require("../audiogram/draw-frames.js");
7
     drawFrames = require("../audiogram/draw-frames.js");
8
 
8
 
9
+const { Image } = require("canvas");
10
+
9
 require("mkdirp").sync(path.join(__dirname, "tmp", "frames"));
11
 require("mkdirp").sync(path.join(__dirname, "tmp", "frames"));
10
 
12
 
11
 var frameDir = path.join(__dirname, "tmp", "frames");
13
 var frameDir = path.join(__dirname, "tmp", "frames");
81
 
83
 
82
       test.error(e);
84
       test.error(e);
83
 
85
 
84
-      const canvas = Canvas.createCanvas();
85
-      var img = canvas.Image;
86
+      const img = new Image();
86
       img.src = f1;
87
       img.src = f1;
87
 
88
 
88
       var bg = getColor(options.backgroundColor || "#fff"),
89
       var bg = getColor(options.backgroundColor || "#fff"),