The fill
function fills the current shape in the Sdf2d
drawing context with an RGBA color. It converts the provided color to pre-multiplied alpha format before blending it with the existing content. This function also resets the internal shape and clipping parameters, preparing the context for subsequent drawing operations.
Sdf2d
instance where the fill operation is performed. The function modifies the result
, shape
, old_shape
, clip
, and has_clip
fields of self
in place.vec4
): An RGBA color used to fill the shape.result
color after the fill operation, reflecting the blended color of the input and the existing content. The shape and clipping parameters are reset after this operation.In this example:
Sdf2d
drawing context using the current position (self.pos
) multiplied by self.rect_size
, which represents the size of the viewport.sdf.box
to draw a rectangle starting at position (10.0, 10.0)
with a width and height of 100.0
units and a corner radius of 5.0
.sdf.fill(#f00)
. The fill
function converts the color to pre-multiplied alpha internally and blends it with the existing content.fill
, the shape and clipping parameters are reset. This means we can define new shapes without manually resetting the state.PI * 0.5
radians) around the point (60.0, 60.0)
, which is the center of the rectangle.sdf.result
, which contains the final rendered color after all drawing operations.fill
function automatically converts the provided RGBA color to pre-multiplied alpha format before blending.fill
. Any shapes defined after fill
will require additional fill or stroke operations to render.