node.js - Multiply drawText from array with node-gm -


have array this:

var myarray=[   { title: 'some title', time: 'some time'},   ...   ]; 

and node-gm code:

gm('bg.png')   .fill("#ffffff")   .font("phenomena-bold.otf", 27)   .drawtext(225, 75, "some text")   .write("result.png", function (err) {     if (!err) console.log('done');   }); 

need add each item myarray .drawtext() shifting y-axis 45px. ideas?

you've asked, wrote , tested it.

take (:

const   gm = require('gm');  const myarray = [   { title: 'some title', time: 'some time'},   { title: 'second title', time: 'second time'} ];  const   image = gm('bg.jpg')             .fill('#ffffff')             .font('arial', 27) // didn't wanted play fonts, used normal default thing (:             .drawtext(225, 75, "some text");  let x = 225; let y = 75; for(const text of myarray) {   y += 45;   image.drawtext(x, y, text.title); } image.write('result.png', err => {   if(err) return console.error(err);   console.log('done'); }); 

prove of work


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -