@unitybase/canvas

Canvas (draw text/pictures on PNG)

   const UBCanvas = require('@unitybase/canvas')
   let canvasWidth = 1200
   let canvasHeight = 300
   let canvas = new UBCanvas(canvasWidth, canvasHeight)

   canvas.setFont('Times New Roman', {r: 0, g: 0, b: 0}, 22, [UBCanvas.FontStyles.Bold])
   canvas.drawText(0, 0, 'Text on the center', canvasWidth - 950, canvasHeight,
      [UBCanvas.TextFormats.Center, UBCanvas.TextFormats.WordBreak]
   )
   canvas.setFont('Times New Roman', {r: 255, g: 0, b: 0}, 18)
   canvas.drawText(300, 0, 'Text on the left, canvasWidth, canvasHeight,
      [UBCanvas.TextFormats.Left, UBCanvas.TextFormats.WordBreak]
   )
   let base64Content = canvas.getContent('bin2base64'); // PNG image encoded as base64

Classes

UBCanvas