The stroke_keep function applies a stroke to the current shape within the Sdf2d drawing context, blending a specified color along the edge of the shape based on the stroke width. This function preserves the existing shape and clipping settings, allowing you to add strokes without resetting the drawing state.
Sdf2d instance where the stroke operation is performed. The function modifies the result field of self in place.vec4): An RGBA color for the stroke.float): The width of the stroke. The stroke width is scaled according to the current scale_factor of the drawing context.In this example:
Sdf2d context using the current position and size of the viewport.sdf.box to draw a rectangle starting at position (10.0, 10.0) with a width and height of 80.0 units and a corner radius of 5.0.stroke_keep to apply a red stroke (#f00) with a width of 2.5 units to the current shape. This stroke is blended along the edges of the shape without altering the existing drawing state.sdf.fill_keep, which allows for layering fills and strokes. In this example, it's commented out.sdf.result, which contains the final rendered color after all drawing operations.stroke_keep function maintains the current shape and clipping settings, so you can perform additional operations on the same shape without resetting the state.width parameter is adjusted based on the scale_factor of the Sdf2d context, ensuring consistent stroke width regardless of transformations.#f00 for red) or as vec4 values.