canvas.setAlpha

canvas.setAlpha(value)

Set the transparency level with which subsequent draw operations should be performed. The default value for alpha is 255 (fully opaque).

Parameters:
    value         An integer value from 0 (transparent) to 255 (opaque). Values outside this range will be clamped.
Example:

// Draw three colored bars with different opacities across the canvas on
// an orange background
function fillRGB(name) {    
    var canvas = sb.getCanvas(name);    
    var rw = canvas.width / 3;    
    canvas.fill(0xff8000);    
    canvas.setAlpha(50);    
    canvas.fillRect(0, 0, rw, canvas.height, 0xff0000);    
    canvas.setAlpha(150);    
    canvas.fillRect(rw, 0, 2*rw, cavas.height, 0x00ff00);    
    canvas.setAlpha(255);    
    canvas.fillRect(2*rw, 0, 3*rw, canvas.height, 0x0000ff);
}
Was this article helpful?
0 out of 0 found this helpful