Дтферы по мировозрениям D&D

Дтферы по мировозрениям D&D

Узнали? Согласны? Кого надо добавить? Пишите в комменты.

const Axios = require('axios'); const Sharp = require('sharp'); const image_filepath = `.\\dnd_alignment_table_smallfont.png`; async function main() { const L_G = [ 503841, //Александр Николаев ]; const N_G = [ 545321, //metadodic ]; const C_G = [ 242053, //Лойсо ]; const L_N = [ 46290, //День РЖД ]; const N_N = [ 525760, //арсений целковый трахал дтф ]; const C_N = [ 83166, //Содачи ]; const L_E = [ 144105, //Шериф, ]; const N_E = [ 485622, //Lolka ]; const C_E = [ 297322, //Обаче 23790, //JfyX 672472, //Злата ]; const image_size = 100; const image_padding = 10; const roundedCorners = Buffer.from( `<svg><rect x="0" y="0" width="${image_size}" height="${image_size}" rx="${image_size}" ry="${image_size}"/></svg>` ); let canvas = await Sharp(image_filepath).toBuffer(); const map = [ {'alignment' : L_G, 'x': 40, 'y': 80}, {'alignment' : N_G, 'x': 670, 'y': 80}, {'alignment' : C_G, 'x': 1300, 'y': 80}, {'alignment' : L_N, 'x': 40, 'y': 430}, {'alignment' : N_N, 'x': 670, 'y': 430}, {'alignment' : C_N, 'x': 1300, 'y': 430}, {'alignment' : L_E, 'x': 40, 'y': 780}, {'alignment' : N_E, 'x': 670, 'y': 780}, {'alignment' : C_E, 'x': 1300, 'y': 780}, ] for (const alignment_map of map) { for (const user_id of alignment_map.alignment) { const k = alignment_map.alignment.indexOf(user_id); const x_index = k % 5; const y_index = Math.floor(k / 5); const response = await fetch(`https://api.dtf.ru/v2.7/subsite?id=${user_id}&markdown=false`); const response_json = await response.json(); let uuid = response_json?.result?.avatar?.data?.uuid; if (!uuid) return 1; const response_avatar = await Axios.get(`https://leonardo.osnova.io/${uuid}/-/scale_crop/${image_size}x${image_size}/-/format/png/`, {responseType: 'arraybuffer'}); let avatar = await Sharp(response_avatar.data) .resize(image_size, image_size) .composite([{ input: roundedCorners, blend: 'dest-in' }]) .png() .toBuffer(); canvas = await Sharp(canvas) .composite([ { input: avatar, left: alignment_map.x + x_index * (image_size + image_padding), top: alignment_map.y + y_index * (image_size + image_padding), blend: 'over' } ]) .png() .toBuffer(); } } await Sharp(canvas).toFile(`.\\output.png`); } main();
23
15
2
2
1
1
1
146 комментариев