浏览代码

Fix bug in non-true-color code

There was a bug caused by 38781d931ec18304f51ed3469faff8387e3cbc55
which prevented color map look-ups sent by rfb.js from working properly,
since display.js expected a single-item array, and rfb.js sent just them
item value itself (a number) instead.  This fixes that, and tweaks the
corresponding test to match that behavior.
Solly Ross 10 年之前
父节点
当前提交
a369a80c24
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 1 1
      include/display.js
  2. 3 3
      tests/test.display.js

+ 1 - 1
include/display.js

@@ -667,7 +667,7 @@ var Display;
             if (this._true_color) {
                 bgr = color;
             } else {
-                bgr = this._colourMap[color[0]];
+                bgr = this._colourMap[color];
             }
 
             var newStyle = 'rgb(' + bgr[2] + ',' + bgr[1] + ',' + bgr[0] + ')';

+ 3 - 3
tests/test.display.js

@@ -353,9 +353,9 @@ describe('Display/Canvas Helper', function () {
             it('should support drawing solid colors with color maps', function () {
                 display._true_color = false;
                 display.set_colourMap({ 0: [0xff, 0, 0], 1: [0, 0xff, 0] });
-                display.fillRect(0, 0, 4, 4, [1]);
-                display.fillRect(0, 0, 2, 2, [0]);
-                display.fillRect(2, 2, 2, 2, [0]);
+                display.fillRect(0, 0, 4, 4, 1);
+                display.fillRect(0, 0, 2, 2, 0);
+                display.fillRect(2, 2, 2, 2, 0);
                 expect(display).to.have.displayed(checked_data);
             });