draw_set_blend_mode

Sets the blend mode for drawing.

Syntax:

draw_set_blend_mode( mode );


Argument Description
mode The blend mode constant to set to (see the table below).


Returns: N/A


Description

When GameMaker: Studio goes to draw a pixel there is a source colour (the colour of the pixel we're going to draw) and a destination colour(the colour that's already in the pixel we're drawing to), so when determining the new colour of the pixel, the source and destination colours are calculated according to the chosen blend mode. Each component of the colours is stored as a floating point value between 0 and 1, and the new colour is calculated by multiply each component of the source colour by some factor and by multiplying each component of destination colour by some other factor and then adding the results together component by component.

This function permits you to set the blend mode in four basic ways using the following constants:

Constant Description Extended Modes
bm_normal Normal blending (the default blend mode). (bm_src_alpha, bm_inv_src_alpha)
bm_add Additive blending. Luminosity values of light areas are added. (bm_src_alpha, bm_one)
bm_subtract Subtractive blending. Luminosity values of light areas are subtracted. (bm_zero, bm_inv_src_colour)
bm_max Max blending. Similar to additive blending. (bm_src_alpha, bm_inv_src_colour)



As you can see these modes are really composites of extended blend modes and those can be found on the page describing draw_set_blend_mode_ext.


Example:

draw_set_blend_mode( bm_add );
draw_circle_colour(100, 100, 50, c_white, c_black, 0);
draw_set_blend_mode( bm_normal );

This will turn the black into transparency, creating a 'glow' effect from the white being strong on the outside and gradually weakening further from the circle centre. The blend mode is reset after the circle is drawn to ensure additive blending is not also applied to everything else after it.


Back: colour And blending
Next: draw_set_blend_mode_ext
© Copyright YoYo Games Ltd. 2018 All Rights Reserved