<commit_before>
/**
 * Canvas
 *
 * @param {Number} width
 * @param {Number} height
 * @param {String} bgColor
 */
function Canvas(width=150, height=100, bgColor='#ffffff')
{
	this.el = document.createElement('canvas');
	this.ctx = this.el.getContext('2d');

	this.el.width = width;
	this.el.height = height;

	this.ctx.fillStyle = bgColor;
	this.ctx.fillRect(0, 0, width, height);
}

function makeQueue(grid=null, setting=null)
{
	if (!(grid && setting)) return null;

	let queue = [];

	function getItemSize(width, col, margin)
	{
		return (width * col) + ((col > 1) ? margin * (col - 1) : 0);
	}

	Object.keys(grid).forEach(k => {
		let block = grid[k];

		queue.push({
			image: block.image || {},

		});

		console.log(block);
	});
}

/**
 * make image
 *
 * @param {HTMLElement} el `.ple-grid` element
 * @param {Object} data
 * @param {Object} option
 * @param {Function} callback
 */
export default function makeImage(el, data={}, option={}, callback=null)
{
	// TODO: exportGrid 해야함.
	// TODO: 이유는 엘리먼트에서 값을(size, position) 추출해내는게 편한거 같음
	// set queue
	//let queue = makeQueue(data.grid, data.setting);
	// set canvas
	let canvas = new Canvas(el.offsetWidth, el.offsetHeight, data.setting.bgColor);


	// TODO: test
	let _output = document.getElementById('makeImageArea');
	_output.innerHTML = '';
	_output.appendChild(canvas.el);
}<commit_msg>makeImage 기능 작업중..<commit_after>import $ from 'jquery/dist/jquery.slim';


/**
 * Canvas
 *
 * @param {Number} width
 * @param {Number} height
 * @param {String} bgColor
 */
function Canvas(width=150, height=100, bgColor='#ffffff')
{
	this.el = document.createElement('canvas');
	this.ctx = this.el.getContext('2d');

	this.el.width = width;
	this.el.height = height;

	this.ctx.fillStyle = bgColor;
	this.ctx.fillRect(0, 0, width, height);
}

function exportGrid(el, grid)
{
	const $items = $(el).children();
	let result = [];

	$items.each((key, item) => {
		let $item = $(item);
		result.push({
			key: $item.data('key'),
			x: $item.position().left,
			y: $item.position().top,
			width: $item.width(),
			height: $item.height(),
			image: grid[$item.data('key')].image
		});
	});

	return result;
}

// function makeQueue(grid=null, setting=null)
// {
// 	if (!(grid && setting)) return null;
//
// 	let queue = [];
//
// 	function getItemSize(width, col, margin)
// 	{
// 		return (width * col) + ((col > 1) ? margin * (col - 1) : 0);
// 	}
//
// 	Object.keys(grid).forEach(k => {
// 		let block = grid[k];
//
// 		queue.push({
// 			image: block.image || {},
// 		});
// 		console.log(block);
// 	});
// }


/**
 * make image
 *
 * @param {HTMLElement} el `.ple-grid` element
 * @param {Object} data
 * @param {Object} option
 * @param {Function} callback
 */
export default function makeImage(el, data={}, option={}, callback=null)
{
	// TODO: exportGrid 해야함.
	// TODO: 이유는 엘리먼트에서 값을(size, position) 추출해내는게 편한거 같음
	const grid = exportGrid(el, data.grid);
	console.log(grid);

	// set queue
	//let queue = makeQueue(data.grid, data.setting);
	// set canvas
	let canvas = new Canvas(el.offsetWidth, el.offsetHeight, data.setting.bgColor);

	// TODO: test
	let _output = document.getElementById('makeImageArea');
	_output.innerHTML = '';
	_output.appendChild(canvas.el);
}
{'fraction_non_alphanumeric': 0.19256965944272444, 'fraction_numerical': 0.007430340557275541, 'mean_word_length': 3.5125698324022347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4654468', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1236, 'n_words': 267}