From 51dd99d7015de079a902748040b60c94ce0d942f Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Mon, 24 Aug 2015 19:34:30 -0400 Subject: [PATCH] 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. --- include/display.js | 2 +- tests/test.display.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/display.js b/include/display.js index 8053002..6bf89bd 100644 --- a/include/display.js +++ b/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] + ')'; diff --git a/tests/test.display.js b/tests/test.display.js index 56dfc22..32a92e2 100644 --- a/tests/test.display.js +++ b/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); });