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
const{ writeFileSync }=require('fs');const{ Application, Text }=require('@pixi/node');constJimp=require('jimp');constapp=newApplication({width: 500,height: 300,backgroundAlpha: 0,antialias: true,preserveDrawingBuffer: true,premultipliedAlpha: false,});constmain=async()=>{constinstance=newText('星星之火\n可以燎原',{align: 'right',fontSize: 80,fill: '#fff',fontFamily: 'SimHei',});instance.x=30;instance.y=30;instance.alpha=0.8;app.stage.addChild(instance);app.renderer.render(app.stage);console.log(instance.canvas);constbuffer=app.view.toBuffer('raw');// writeFileSync('./tmp/pixi.png', app.view.toBuffer('image/png');newJimp({data: buffer,width: 500,height: 300},(err,image)=>{console.log(err,image.hasAlpha());image.scan(0,0,500,300,function(x,y,idx){// x, y is the position of this pixel on the image// idx is the position start position of this rgba tuple in the bitmap Buffer// this is the imagevarred=this.bitmap.data[idx+0];vargreen=this.bitmap.data[idx+1];varblue=this.bitmap.data[idx+2];varalpha=this.bitmap.data[idx+3];console.log(red,green,blue,alpha/255);// rgba values run from 0 - 255// e.g. this.bitmap.data[idx] = 0; // removes red from this pixel});image.quality(100).write('./tmp/jimp.png');});// 用完销毁// process.exit(0);};main();
constinstance=newText('星星之火\n可以燎原',{align: 'right',fontSize: 80,// bake the alpha into the fillfill: 'rgba(255, 255, 255, 0.8)',// '#fff',fontFamily: 'SimHei',});instance.x=30;instance.y=30;// instance.alpha = 0.8; // Declare the texture to be pmainstance.texture.baseTexture.alphaMode=ALPHA_MODES.PREMULTIPLIED_ALPHA;
this font color is #fff
result
The text was updated successfully, but these errors were encountered: