-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgarden.js
36 lines (24 loc) · 878 Bytes
/
garden.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var jimp = require('jimp');
var fs = require('fs');
if(fs.existsSync('loutres.json'))
loutres = JSON.parse(fs.readFileSync('loutres.json'));
async function dessine() {
const garden = await jimp.read('garden.jpg');
const loutre = await jimp.read('loutre.png');
const w = garden.bitmap.width;
const h = garden.bitmap.height;
const lw = loutre.bitmap.width;
const lh = loutre.bitmap.height;
console.log(jimp.FONT_SANS_32_BLACK);
const font = await jimp.loadFont(jimp.FONT_SANS_16_BLACK);
for(l in loutres){
const x = Math.floor((w-lw)*Math.random());
const y = Math.floor((h-lh)*Math.random());
await garden.blit(loutre, x, y);
await garden.print(font, x, y, loutres[l].name);
console.log(loutres[l].name)
console.log(x+","+y);
}
await garden.write('gwl.jpg');
}
dessine();