The fill_keep_premul
function blends a pre-multiplied source color with the current result color of the SDF2D drawing context, preserving the existing content while applying the new fill.
Sdf2d
instance where the blending operation is performed. The function modifies the result
field of self
in place.vec4
): A pre-multiplied RGBA color to be blended with the existing content.In this example:
Sdf2d
drawing context using the current position (self.pos
) and size (self.rect_size
) of the viewport.(10.0, 10.0)
with a width and height of 80.0
units and rounded corners with a radius of 5.0
.fill_keep_premul
function is used to blend a semi-transparent red color (vec4(1.0, 0.0, 0.0, 0.5)
) with the existing content. This preserves any previous fills or drawings while adding the new color.PI * 0.25
radians) around the point (50.0, 50.0)
, which is the center of the rectangle.This function is particularly useful when you want to add a new fill color to your drawing without overwriting the existing content, allowing for complex blending effects in your shaders.