Closed mdvanes closed 6 years ago
sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
npm i --save canvas
var Canvas = require('canvas')
, Image = Canvas.Image
, canvas = new Canvas(200, 200)
, ctx = canvas.getContext('2d');
const crypto = require('crypto');
const getSHA1ofJSON = function(input){
return crypto.createHash('sha1').update(JSON.stringify(input)).digest('hex')
}
const x = getSHA1ofJSON({'this':'too'})
// sha1 always 40 chars long
console.log('sha1 is', x);
ctx.font = '30px Impact';
ctx.rotate(.1);
ctx.fillText("Awesome!", 50, 100);
var te = ctx.measureText('Awesome!');
ctx.strokeStyle = 'rgba(0,0,0,0.5)';
ctx.beginPath();
ctx.lineTo(50, 102);
ctx.lineTo(50 + te.width, 102);
ctx.stroke();
//console.log('<img src="' + canvas.toDataURL() + '" />');
var base64Data = canvas.toDataURL().replace(/^data:image\/png;base64,/, "");
require("fs").writeFile("out.png", base64Data, 'base64', function(err) {
console.log(err);
});
Also for retro post json
hash of the content or title+date of the article
Shapes:
Emulate pencil drawing with fuzzy mesh
NPM package name:
pg-post-cover
(pg is procedurally generated) On-hover of each cover image: show info about the name and how it was created