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?
(bch?Math.max(bch>>4,1):0);
Math.max(bch>>4,0)
If so, make fbuf a Uint8ClampedArray and you can remove the max altogether... Maybe:
fbuf
Uint8ClampedArray
max
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;
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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);
? WouldMath.max(bch>>4,0)
work?If so, make
fbuf
aUint8ClampedArray
and you can remove themax
altogether... Maybe:to: