Merge branch 'master' into aliabd/saliency

This commit is contained in:
Abubakar Abid 2019-07-25 21:54:21 -07:00
commit 9b110611d7
3 changed files with 4 additions and 12 deletions

View File

@ -54,9 +54,9 @@ const sketchpad_input = {
},
output: function(data) {
this.target.find(".saliency_holder").removeClass("hide");
var ctx = this.target.find(".saliency")[0].getContext('2d');
let ctx = this.target.find(".saliency")[0].getContext('2d');
let dimension = this.target.find(".saliency").width();
console.log(data, dimension, dimension);
ctx.clearRect(0,0,dimension,dimension);
paintSaliency(data, dimension, dimension, ctx);
},
clear: function() {

View File

@ -16,7 +16,7 @@ const textbox_input = {
let text = this.target.find(".input_text").val();
let index = 0;
data.forEach(function(value, index) {
html += `<span style='background-color:rgba(255,0,0,${value})'>${text.charAt(index)}</span>`;
html += `<span style='background-color:rgba(0,0,255,${value})'>${text.charAt(index)}</span>`;
})
$(".input_text_saliency").html(html);
},

View File

@ -47,15 +47,7 @@ function paintSaliency(data, width, height, ctx) {
data.forEach(function(row) {
var c = 0
row.forEach(function(cell) {
if (cell < 0.25) {
ctx.fillStyle = "white";
} else if (cell < 0.5) {
ctx.fillStyle = "yellow";
} else if (cell < 0.75) {
ctx.fillStyle = "orange";
} else {
ctx.fillStyle = "red";
}
ctx.fillStyle = `rgba(${(1 - cell) * 255},${(1 - cell) * 255},255,0.5)`;
ctx.fillRect(c * cell_width, r * cell_height, cell_width, cell_height);
c++;
})