so://phie

outline

A web-based drawing app
git clone git://soophie.de/outline

blob: eec67d1c2e91abf336d6063c098df3f42d0a8111 (657 bytes)[doc][blame][raw]

1export default {

2 uuid: function() {

3 return 'xxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {

4 let r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);

5 return v.toString(16);

6 });

7 },

8 luma: function(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 },

15 download: function(file, data) {

16 let link = document.createElement('a');

17 link.classList.add('hidden');

18 link.download = file;

19 link.href = data;

20 document.body.appendChild(link);

21 link.click();

22 }

23};