Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <html> |
michael@0 | 3 | <body> |
michael@0 | 4 | <div> |
michael@0 | 5 | <canvas id="c1" width="400" height="400"></canvas> |
michael@0 | 6 | <canvas id="c2" width="400" height="400"></canvas> |
michael@0 | 7 | </div> |
michael@0 | 8 | <script type="text/javascript"> |
michael@0 | 9 | var canv1 = document.getElementById('c1'); |
michael@0 | 10 | var canv2 = document.getElementById('c2'); |
michael@0 | 11 | var ctx1 = canv1.getContext('2d'); |
michael@0 | 12 | var ctx2 = canv2.getContext('2d'); |
michael@0 | 13 | |
michael@0 | 14 | ctx1.strokeStyle = '#FF0000'; |
michael@0 | 15 | ctx1.moveTo(10, 10); |
michael@0 | 16 | ctx1.lineTo(390, 390); |
michael@0 | 17 | ctx1.stroke(); |
michael@0 | 18 | |
michael@0 | 19 | function doTest() |
michael@0 | 20 | { |
michael@0 | 21 | // Save img data |
michael@0 | 22 | var imgData = ctx1.getImageData(0, 0, canv1.width, canv1.height); |
michael@0 | 23 | |
michael@0 | 24 | // Resize canvas - seems to cause the bug |
michael@0 | 25 | canv1.width = 0; |
michael@0 | 26 | canv1.height = 0; |
michael@0 | 27 | canv1.width = 400; |
michael@0 | 28 | canv1.height = 400; |
michael@0 | 29 | |
michael@0 | 30 | // Put image data from ctx1 to ctx2 |
michael@0 | 31 | ctx2.putImageData(imgData, 0, 0); |
michael@0 | 32 | |
michael@0 | 33 | // Draw canvas2 on canvas1 |
michael@0 | 34 | ctx1.drawImage(canv2, 0, 0); |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | doTest(); |
michael@0 | 38 | </script> |
michael@0 | 39 | </body> |
michael@0 | 40 | </html> |