OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body> | |
esprehn
2017/01/27 19:44:39
you can leave out html and body
fserb
2017/01/27 19:54:47
Done all.
| |
4 | |
5 <canvas id='output0' width='100' height='100'></canvas> | |
6 <canvas id='output1' width='100' height='100'></canvas> | |
7 <canvas id='output2' width='100' height='100'></canvas> | |
8 <canvas id='output3' width='100' height='100'></canvas> | |
9 <canvas id='output4' width='100' height='100'></canvas> | |
10 <canvas id='output5' width='100' height='100'></canvas> | |
11 <canvas id='output6' width='100' height='100'></canvas> | |
12 <canvas id='output7' width='100' height='100'></canvas> | |
13 <canvas id='output8' width='100' height='100'></canvas> | |
14 <canvas id='output9' width='100' height='100'></canvas> | |
15 <canvas id='output10' width='100' height='100'></canvas> | |
16 <canvas id='output11' width='100' height='100'></canvas> | |
17 | |
18 <script> | |
19 var patternCanvas = document.createElement('canvas'); | |
20 patternCanvas.width = 30; | |
21 patternCanvas.height = 30; | |
22 var patternCtx = patternCanvas.getContext('2d'); | |
23 patternCtx.fillStyle = '#A00'; | |
24 patternCtx.fillRect(0, 0, 15, 15); | |
25 patternCtx.fillStyle = '#0A0'; | |
26 patternCtx.fillRect(15, 0, 15, 15); | |
27 patternCtx.fillStyle = '#00A'; | |
28 patternCtx.fillRect(0, 15, 15, 15); | |
29 patternCtx.fillStyle = "#AA0"; | |
30 patternCtx.fillRect(15, 15, 15, 15); | |
31 | |
32 var paint = function(id, filter) { | |
33 var oc = new OffscreenCanvas(100, 100); | |
34 var ctx = oc.getContext('2d'); | |
35 ctx.filter = filter; | |
36 ctx.drawImage(patternCanvas, 5, 5); | |
37 ctx.drawImage(patternCanvas, 35, 35); | |
38 ctx.drawImage(patternCanvas, 65, 65); | |
39 | |
40 var c = document.getElementById(id); | |
41 var c = c.getContext('2d'); | |
42 c.drawImage(oc, 0, 0); | |
43 }; | |
44 | |
45 paint('output0', "none"); | |
46 paint('output1', "blur(10px)"); | |
47 paint('output2', "brightness(40%)"); | |
48 paint('output3', "contrast(20%)"); | |
49 paint('output4', "drop-shadow(0 0 5px green)"); | |
50 paint('output5', "grayscale(100%)"); | |
51 paint('output6', "invert(100%)"); | |
52 paint('output7', "opacity(50%)"); | |
53 paint('output8', "saturate(20%)"); | |
54 paint('output9', "sepia(100%)"); | |
55 paint('output10', "sepia(1) hue-rotate(200deg)"); | |
56 paint('output11', "url(#url)"); | |
57 | |
58 </script> | |
59 </body> | |
60 </html> | |
OLD | NEW |