You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue getting transparent to work for me.
I'm creating GIFs from canvas data. The transparent will be fine for some frames and then not for others. I'm not sure what's going on or how to solve this.
As you can see there are a few frames where the transparency is replaced just fine. Then a few frames where it renders as the "bright-green" color that I'm setting as the "transparency color".
The color pallet I use is set and known, there are only 57 of them, so I know that the "bright-green" is not actually used in this art at all.
This is the code that I'm using to generate the GIF files. I would love some help here please!
letencoder=newGIFEncoder2(canvas.width,canvas.height);letstream=encoder.createReadStream();stream.pipe(res)stream.pipe(fs.createWriteStream(`./GIFS/${fileName}.gif`))encoder.start();encoder.setRepeat(0);// 0 for repeat, -1 for no-repeatencoder.setDelay(thingInfo.speed);// frame delay in msencoder.setQuality(1);// image quality. 10 is default.encoder.setThreshold(0);
# makethiscolortransparentencoder.setTransparent("0x00FF15")
# cyclethrougheachframeintheanimationframes.forEach((frame,index)=>{if(index<=frames.length){
#clear thecontextofpreviousframedatactx.clearRect(0,0,canvas.width,canvas.height);
# foreachframecyclethroughthepixelcolordataanddraweachoneasarectangleframe.forEach((letter,index)=>{
# matchthe"pixel letter"tothecorrespondinghexcolor
## Ifthe"pixel letter"isAthensetitasourtransparentpixelhexif(letter==="A")ctx.fillStyle="#00ff15"elsectx.fillStyle=letter_to_color[letter];letrowBefore=Math.floor(index/numOfPixels)letrowAdj=(pixelSize*rowBefore)lety=Math.floor(index/numOfPixels)letx=(index-(y*numOfPixels))*pixelSizectx.fillRect(x,rowAdj,pixelSize,pixelSize);
# Addtexteachframeif(!shareLink){ctx.font=`21pt Roboto`;ctx.textBaseline='middle';ctx.textAlign='center';ctx.strokeStyle=watermark.strokeColor;ctx.lineWidth=1;ctx.miterLimit=2;ctx.strokeText(config.watermark,canvas.width/2,canvas.height-(canvas.height/7));ctx.fillStyle=watermark.fillColor;ctx.fillText(config.watermark,canvas.width/2,canvas.height-(canvas.height/7));}})
# addframetotheGIFencoder.addFrame(ctx);}})
# CreateGIFencoder.finish();
The text was updated successfully, but these errors were encountered:
I'm having an issue getting transparent to work for me.
I'm creating GIFs from canvas data. The transparent will be fine for some frames and then not for others. I'm not sure what's going on or how to solve this.
This is an example of an auto generated GIF file from some Canvas data and this is an example of the canvas data it's derived from.
As you can see there are a few frames where the transparency is replaced just fine. Then a few frames where it renders as the "bright-green" color that I'm setting as the "transparency color".
The color pallet I use is set and known, there are only 57 of them, so I know that the "bright-green" is not actually used in this art at all.
This is the code that I'm using to generate the GIF files. I would love some help here please!
The text was updated successfully, but these errors were encountered: