
'use strict';

const fs = require('fs')
const root_main = './src/main/resources/assets/overdrive_that_matters/textures/block/decorative/'
const child_process = require('child_process')

const colors = [
	['orange', [245, 116, 16]],
	['magenta', [186, 63, 175]],
	['light_blue', [59, 180, 219]],
	['yellow', [252, 199, 36]],
	['lime', [111, 187, 24]],
	['pink', [243, 139, 170]],
	['gray', [62, 66, 70]],
	['light_gray', [140, 140, 131]],
	['cyan', [22, 134, 145]],
	['purple', [116, 38, 169]],
	['blue', [51, 53, 155]],
	['brown', [114, 71, 40]],
	['green', [84, 109, 28]],
	['red', [156, 37, 34]],
	['black', [31, 31, 35]],
	['white', [235, 235, 235]],
]

process.stderr.setMaxListeners(40)
process.stdout.setMaxListeners(40);

(async function() {
	for (const [base, overlay, nameBase] of [['tritanium_door_base_top', 'tritanium_door_color_top', 'tritanium_door_top'], ['tritanium_door_base_bottom', 'tritanium_door_color_bottom', 'tritanium_door_bottom']]) {
		for (const [name, rgb] of colors) {
			const magick = child_process.spawn('magick', [
				'convert',

				`${root_main}${base}.png`,

				'(',
					`${root_main}${overlay}.png`,
					'-size', '16x16',
					`xc:rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`,
					'-channel', 'rgb',
					'-compose', 'Multiply',
					'-composite',
				')',

				'-compose', 'Over',
				'-composite',

				`${root_main}/${nameBase}_${name}.png`])

			magick.stdout.pipe(process.stdout)
			magick.stderr.pipe(process.stderr)
		}
	}
})()
