draw_clear_alpha

Clears the entire screen with an alpha-blended given colour.

Syntax:

GML Code Example

draw_clear_alpha(col, alpha);


Argument Description
col The colour with which the screen will be cleared
alpha The transparency of the colour with which the screen will be cleared


Returns: N/A


Description

This function can be used to clear the entire screen with a given colour and the alpha component of the destination is set to the value you have set - this function does not do any blending as it works but any subsequent blend operations can be set up to use the destination alpha that you have set. This is only for use in the draw event of an instance (it will not show if used in any other event), and it can also be very useful for clearing surfaces when they are newly created.

It is worth noting that when using the HTML5 module, you can use this function to make the canvas background transparent, which will then permit any images being used in the host HTML to be seen with the game running over them. To achieve this effect you must first go into the room editor and untick the "Draw Background colour" option from the Background Tab, then untick the option "Clear Background with Window colour" found on the Views Tab. Finally, you will need to make a new object, place it in the first room of the game, and assign it a very low depth (for example, -1000000). Then in the Pre Draw event use this function to set the canvas alpha to the colour and transparency that you wish it to have.


Example:

GML Code Example

draw_clear_alpha(c_red, 0.5);

This will clear the screen with 50% (0.5) transparency with the colour red.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here