OLD | NEW |
(Empty) | |
| 1 // Generates code for a CSS paint API function which logs the given properties |
| 2 // to the console. |
| 3 // |
| 4 // Usage: |
| 5 // generatePaintStyleLogging([ |
| 6 // '--foo', |
| 7 // 'line-height', |
| 8 // ]); |
| 9 |
| 10 function generatePaintStyleLogging(properties) { |
| 11 const json = JSON.stringify(properties); |
| 12 return ` |
| 13 registerPaint('test', class { |
| 14 static get inputProperties() { return ${json}; } |
| 15 paint(ctx, geom, styleMap) { |
| 16 const properties = styleMap.getProperties().sort(); |
| 17 for (let i = 0; i < properties.length; i++) { |
| 18 const value = styleMap.get(properties[i]); |
| 19 console.log(properties[i] + ': ' + (value ? value.cssString
: '[null]')); |
| 20 } |
| 21 } |
| 22 }); |
| 23 `; |
| 24 } |
OLD | NEW |