OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../resources/testharness.js"></script> | |
3 <script src="../../resources/testharnessreport.js"></script> | |
4 | |
5 <script> | |
6 test(function() { | |
7 var width = 50; | |
8 var height = 50; | |
9 var offscreenCanvas1 = new OffscreenCanvas(width, height); | |
10 var ctx1 = offscreenCanvas1.getContext('2d'); | |
11 var offscreenCanvas2 = new OffscreenCanvas(width, height); | |
12 var ctx2 = offscreenCanvas2.getContext('2d'); | |
13 | |
14 ctx2.fillStyle = 'rgba(12, 34, 56, 255)'; | |
15 ctx2.fillRect(0, 0, 10, 10); | |
16 ctx1.fillStyle = 'rgba(24, 68, 108, 255)'; | |
17 ctx1.fillRect(0, 0, width, height); | |
18 ctx1.globalCompositeOperation = 'source-in'; | |
xlai (Olivia)
2016/11/18 15:16:26
Hmmm, I think it's more important to test this fun
| |
19 ctx1.drawImage(offscreenCanvas2, 0, 0); | |
20 | |
21 var color = ctx1.getImageData(25, 25, 1, 1).data; | |
22 assert_approx_equals(color[0], 0, 5); | |
23 assert_approx_equals(color[1], 0, 5); | |
24 assert_approx_equals(color[2], 0, 5); | |
25 assert_approx_equals(color[3], 0, 5); | |
26 | |
27 color = ctx1.getImageData(5, 5, 1, 1).data; | |
28 assert_approx_equals(color[0], 12, 5); | |
29 assert_approx_equals(color[1], 34, 5); | |
30 assert_approx_equals(color[2], 56, 5); | |
31 assert_approx_equals(color[3], 255, 5); | |
32 }, 'Test globalCompositeOperation API on OffscreenCanvas'); | |
33 | |
34 </script> | |
OLD | NEW |