Skip to content
This repository
Browse code

Fix the 140px test image to be exactly 50%. Results correct for it.

Plus minor renaming for some single-letter variables.
  • Loading branch information...
commit f392f94f4d6852a86a162dc7502cac793e1d7a7d 1 parent f9b496e
M. Kelley Harris mkelleyharris authored
12 client/plugins/efficiency/efficiency.js
@@ -28,16 +28,16 @@
28 28 return div.find('p:first').text("" + (value.toFixed(1)) + "%");
29 29 };
30 30 getImageData = function(div) {
31   - var c, d, h, imageData, img, w;
  31 + var can, ctx, h, imageData, img, w;
32 32 img = new Image;
33 33 img.src = $(div).data('item').url;
34 34 w = img.width;
35 35 h = img.height;
36   - c = $('<canvas id="myCanvas" width="#{w}" height="#{h}">');
37   - d = c.get(0).getContext("2d");
38   - d.drawImage(img, 0, 0);
39   - wiki.log('efficiency img w, h', w, h, 'c w, h ', c.width(), c.height());
40   - imageData = d.getImageData(0, 0, w, h);
  36 + can = $('<canvas id="myCanvas" width="#{w}" height="#{h}">');
  37 + ctx = can.get(0).getContext("2d");
  38 + ctx.drawImage(img, 0, 0);
  39 + wiki.log('efficiency img w, h', w, h, 'canvas w, h ', can.width(), can.height());
  40 + imageData = ctx.getImageData(0, 0, w, h);
41 41 return imageData.data;
42 42 };
43 43 calculatePercentage = function(data) {
BIN  client/plugins/efficiency/pages/high-contrast-test-image-white-area-50per-140px.png
14 client/test/testclient.js
@@ -2512,22 +2512,22 @@ require.define("/plugins/efficiency/efficiency.js",function(require,module,expor
2512 2512 return div.find('p:first').text("" + (value.toFixed(1)) + "%");
2513 2513 };
2514 2514 getImageData = function(div) {
2515   - var c, d, h, imageData, img, w;
  2515 + var can, ctx, h, imageData, img, w;
2516 2516 img = new Image;
2517 2517 img.src = $(div).data('item').url;
2518 2518 w = img.width;
2519 2519 h = img.height;
2520   - c = $('<canvas id="myCanvas" width="#{w}" height="#{h}">');
2521   - d = c.get(0).getContext("2d");
2522   - d.drawImage(img, 0, 0);
2523   - wiki.log('efficiency img w, h', w, h, 'c w, h ', c.width(), c.height());
2524   - imageData = d.getImageData(0, 0, w, h);
  2520 + can = $('<canvas id="myCanvas" width="#{w}" height="#{h}">');
  2521 + ctx = can.get(0).getContext("2d");
  2522 + ctx.drawImage(img, 0, 0);
  2523 + wiki.log('efficiency img w, h', w, h, 'c w, h ', can.width(), can.height());
  2524 + imageData = ctx.getImageData(0, 0, w, h);
2525 2525 return imageData.data;
2526 2526 };
2527 2527 calculatePercentage = function(data) {
2528 2528 var lumas;
2529 2529 lumas = window.plugins.efficiency.getGrayLumaFromRGBT(data);
2530   - return window.plugins.efficiency.calculateStrategy_GrayIterativeClustering(lumas);
  2530 + return window.plugins.efficiency.calculateStrategy_GrayBinary(lumas);
2531 2531 };
2532 2532 return display(calculate(locate()));
2533 2533 },

0 comments on commit f392f94

Please sign in to comment.
Something went wrong with that request. Please try again.