Sfoglia il codice sorgente

Fixes in initialize-canvas.js. Updated tests

Dmitriy Slipak 4 anni fa
parent
commit
77aea7e9ec
2 ha cambiato i file con 7 aggiunte e 4 eliminazioni
  1. 4 2
      audiogram/initialize-canvas.js
  2. 3 2
      test/frame-test.js

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

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

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

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