import * as Canvas from "canvas" ; import * as fs from "fs" ; import IPlatform from "./IPlatform" ; export default class NodePlatform implements IPlatform { public name = "NODE" ; public buffers = [ ] ; public Image = Canvas . Image ; public Promise = Promise ; public getBuffer ( width , height , clear ) { return Canvas . createCanvas ( width , height ) ; } public freeBuffer ( buffer ) { } public loadAsset ( img , path , loaded , error ) { fs . readFile ( path , ( err , data ) => { if ( err ) { error ( ) ; return ; } img . src = data ; loaded ( ) ; } ) ; } public requestAnimationFrame ( cb ) { setImmediate ( cb ) ; } }