| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../resources/run-after-layout-and-paint.js"></script> |
| 5 <style> |
| 6 #output { |
| 7 width: 500px; |
| 8 height: 500px; |
| 9 background-image: paint(shapes); |
| 10 } |
| 11 </style> |
| 12 </head> |
| 13 <body> |
| 14 <div id="output"></div> |
| 15 |
| 16 <script id="code" type="text/worklet"> |
| 17 registerPaint('shapes', class { |
| 18 paint(ctx) { |
| 19 var fillShape = function(x, y) { |
| 20 ctx.beginPath(); |
| 21 ctx.arc(x, y, 100, 0, Math.PI*2, true); |
| 22 ctx.arc(x, y, 50, 0, Math.PI*2, false); |
| 23 ctx.fill(); |
| 24 }; |
| 25 |
| 26 var gradient = ctx.createLinearGradient(0, 0, 300, 0); |
| 27 gradient.addColorStop(0, 'rgba(0, 0, 255, 0.5)'); |
| 28 gradient.addColorStop(1, 'rgba(0, 0, 255, 0.5)'); |
| 29 |
| 30 ctx.save(); |
| 31 ctx.fillStyle = gradient; |
| 32 ctx.shadowColor = 'rgba(255, 0, 0, 0.5)'; |
| 33 ctx.shadowOffsetX = 250; |
| 34 |
| 35 // Alpha shadow. |
| 36 ctx.shadowBlur = 0; |
| 37 fillShape(150, 150); |
| 38 |
| 39 // Blurry shadow. |
| 40 ctx.shadowBlur = 10; |
| 41 fillShape(150, 400); |
| 42 |
| 43 ctx.rotate(Math.PI/2); |
| 44 |
| 45 ctx.restore(); |
| 46 } |
| 47 }); |
| 48 </script> |
| 49 |
| 50 <script> |
| 51 if (window.testRunner) { |
| 52 testRunner.waitUntilDone(); |
| 53 } |
| 54 |
| 55 var blob = new Blob([document.getElementById('code').textContent]); |
| 56 paintWorklet.import(URL.createObjectURL(blob)).then(function() { |
| 57 runAfterLayoutAndPaint(function() { |
| 58 if (window.testRunner) { |
| 59 testRunner.notifyDone(); |
| 60 } |
| 61 }); |
| 62 }); |
| 63 </script> |
| 64 </body> |
| 65 </html> |
| OLD | NEW |