function savePng(canvas, name) {
saveImage(canvas.toDataURL('image/png'), name, 'png')
}
function saveJpg(canvas, name) {
saveImage(canvas.toDataURL('image/jpg'), name, 'jpg')
}
function saveImage(dataUrl, name, type) {
const link = document.createElement('a')
link.href = dataUrl
link.download = `${name}.${type}`
link.click()
URL.revokeObjectURL(link.href)
}
'html | javascript' 카테고리의 다른 글
html javascript - array remove (splice) (0) | 2024.08.23 |
---|---|
html javascript - array filter (0) | 2024.08.21 |
html javascript - canvas imageData (0) | 2024.08.19 |
html javascript - array, object copy (0) | 2024.08.19 |
html javascript - easing circular (0) | 2024.08.19 |