web-dsp
web-dsp copied to clipboard
No error, but still not working...
I have this code, can you explain why this doesn't show any result?
var c = document.getElementById("c2");
var ctx = c.getContext("2d");
// Create gradient
var grd = ctx.createLinearGradient(0, 0, 200, 0);
grd.addColorStop(0, "red");
grd.addColorStop(1, "white");
// Fill with gradient
ctx.fillStyle = grd;
ctx.fillRect(10, 10, 150, 80);
/*webassembly*/
let wam;
loadWASM()
.then(module => {
wam = module;
}).catch((err) => {
console.log('Error in fetching module: ', err);
}).then(() => {
window.onload = (() => {
var pixels = ctx.getImageData(0, 0, 400, 300);
//console.log(pixels);
var xx = pixels.data.set(wam.goodMorning(pixels.data, 400, 300));
//var xx = wam.goodMorning(pixels.data, 400, 300);
//console.log(xx);
pixels.data.set(xx);
})();
});