A web-based drawing app
git clone git://soophie.de/outline
blob: be9c1cf04e53837ac81863cc1c6a5d40053ab54e (796 bytes)[doc][blame][raw]
1
function uuid() {2
return 'xxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {3
let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);4
return v.toString(16);5
});6
}8
function luma(color) {9
color = color.substr(1);10
let r = parseInt(color.substr(0, 2), 16);11
let g = parseInt(color.substr(2, 4), 16);12
let b = parseInt(color.substr(4, 6), 16);13
return ((r * 0.299) + (g * 0.587) + (b * 0.114)) > 50;14
}16
function download(file, data) {17
let link = document.createElement('a');18
link.classList.add('hidden');19
link.download = file;20
link.href = data;21
document.body.appendChild(link);22
link.click();23
}25
function isMobile() {26
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent.toLowerCase());27
}29
export { uuid, luma, download, isMobile };