Composition Modes

    • source-over
    • source-in
    • source-out
    • source-atop
    1. property var operation : [
    2. 'source-over', 'source-in', 'source-over',
    3. 'source-atop', 'destination-over', 'destination-in',
    4. 'destination-out', 'destination-atop', 'lighter',
    5. 'copy', 'xor', 'qt-clear', 'qt-destination',
    6. 'qt-multiply', 'qt-screen', 'qt-overlay', 'qt-darken',
    7. 'qt-hard-light', 'qt-soft-light', 'qt-difference',
    8. 'qt-exclusion'
    9. ]
    10. onPaint: {
    11. var ctx = getContext('2d')
    12. for(var i=0; i<operation.length; i++) {
    13. var dx = Math.floor(i%6)*100
    14. var dy = Math.floor(i/6)*100
    15. ctx.fillStyle = '#33a9ff'
    16. ctx.fillRect(10+dx,10+dy,60,60)
    17. ctx.globalCompositeOperation = root.operation[i]
    18. ctx.fillStyle = '#ff33a9'
    19. ctx.globalAlpha = 0.75
    20. ctx.beginPath()
    21. ctx.arc(60+dx, 60+dy, 30, 0, 2*Math.PI)
    22. ctx.closePath()
    23. ctx.fill()
    24. ctx.restore()
    25. }