You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Well, at the moment you have a bunch of commented out code in the FOR loop. Just removing that would help a lot (or you could turn on minification?).

    Also, What happens with (bch?Math.max(bch>>4,1)­:0);? Would Math.max(bch>>4,0) work?

    If so, make fbuf a Uint8ClampedArray and you can remove the max altogether... Maybe:

            rch*=mult;
            gch*=mult;
            bch*=mult;
    
            this.fbuf[i*4]=(this.ison?(gdim|224):224­­);
            this.fbuf[1+i*4]=(bch?Math.max(bch>>4,1)­­:0);
            this.fbuf[2+i*4]=(gch?Math.max(gch>>4,1)­­:0);
            this.fbuf[3+i*4]=(rch?Math.max(rch>>4,1)­­:0);
    

    to:

    var fi = 0;
    
            this.fbuf[fi++]=this.ison?(gdim|224):224­­;
            this.fbuf[fi++]=(mult*bch)>>4;
            this.fbuf[fi++]=(mult*gch)>>4;
            this.fbuf[fi++]=(mult*rch)>>4;
    
About

Avatar for Gordon @Gordon started