diff --git a/app.js b/app.js index 9af3389..c042a21 100644 --- a/app.js +++ b/app.js @@ -1,11 +1,46 @@ /*********************************************************** Thumbnail Maker v 1.2.1 Made by Wonkook Lee (oneook) +Edited by devcomfort (2021.11.22.) © All Rights Reserved ************************************************************/ +/** + * @TODO download_canvas 함수를 실제 페이지에 적용하기 + */ + "use strict" +/** UUID 생성 함수 + * @returns {UUID} + */ +function uuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, + v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); +} + + +/** DOWNLOAD API + * @link http://danml.com/download.html + * @param {Element} canvas 엘리먼트를 넣으면, 다운로드 됩니다. + * @return {undefined} + */ + +const download_canvas = (canvas_element) => { + const mime_type = "image/jpeg" + + canvas_element.toBlob( + (blob) => { + download(blob, `${uuid()}.jpg`, mime_type) + }, + mime_type, + 0.95 + ); +}; + // HTML2CANVAS API const produceImageBtn = document.querySelector('#export'); @@ -272,4 +307,4 @@ init(); const msg = '%cWonkook Lee ⓒ oneook'; const css = "font-size: 2em; color: #FEDC45; background-color: #000;font-family: 'Noto Sans KR';"; -console.log(msg, css); +console.log(msg, css); \ No newline at end of file diff --git a/index.html b/index.html index 3ff94e0..5a6608e 100644 --- a/index.html +++ b/index.html @@ -11,6 +11,7 @@ +