PIXI.js 将container导出为图像

 
 
// Create a new app (will auto-add extract plugin to renderer)
const app = new PIXI.Application();

// Draw a red circle
const graphics = new PIXI.Graphics()
    .beginFill(0xFF0000)
    .drawCircle(0, 0, 50);

// Render the graphics as an HTMLImageElement
const image = app.renderer.plugins.extract.image(graphics);
document.body.appendChild(image);

直接调用canvas的toDataURL();将会导出一个透明的图片。

需要调用renderer的plugin里面的extract进行导出

 
 
 

猜你喜欢

转载自blog.csdn.net/kingdomwar/article/details/80538471