blending.js 966 B

1234567891011121314151617181920212223242526272829303132
  1. /*!
  2. {
  3. "name": "canvas blending support",
  4. "property": "canvasblending",
  5. "caniuse": "canvas-blending",
  6. "tags": ["canvas"],
  7. "notes": [{
  8. "name": "W3C Spec",
  9. "href": "https://drafts.fxtf.org/compositing-1/"
  10. },{
  11. "name": "Article",
  12. "href": "https://web.archive.org/web/20171003232921/http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/"
  13. }]
  14. }
  15. !*/
  16. /* DOC
  17. Detects if Photoshop style blending modes are available in canvas.
  18. */
  19. define(['Modernizr', 'createElement', 'test/canvas'], function(Modernizr, createElement) {
  20. Modernizr.addTest('canvasblending', function() {
  21. if (Modernizr.canvas === false) {
  22. return false;
  23. }
  24. var ctx = createElement('canvas').getContext('2d');
  25. // firefox 3 throws an error when setting an invalid `globalCompositeOperation`
  26. try {
  27. ctx.globalCompositeOperation = 'screen';
  28. } catch (e) {}
  29. return ctx.globalCompositeOperation === 'screen';
  30. });
  31. });