The box_x
function draws a rectangle within the Sdf2d
drawing context, allowing you to specify different corner radii for the left and right sides. This enables the creation of rectangles with asymmetric rounded corners along the horizontal axis.
Sdf2d
instance. The function modifies the internal state of self
to include the box shape.float
): The x-coordinate of the lower-left corner of the box.float
): The y-coordinate of the lower-left corner of the box.float
): The width of the box.float
): The height of the box.float
): The radius of the left corners (top-left and bottom-left).float
): The radius of the right corners (top-right and bottom-right).self
to represent the box with the specified corner radii.In this example:
Sdf2d
drawing context using the current position (self.pos
) and size (self.rect_size
) of the viewport.box_x
to draw a rectangle starting at position (10.0, 10.0)
with a width of 100.0
units and a height of 80.0
units. The left corners (r_left
) have a radius of 5.0
, and the right corners (r_right
) have a radius of 15.0
.sdf.fill(#f00)
.sdf.result
, which contains the final rendered color.(x, y)
. Width (w
) and height (h
) define the size of the box.box_x
, use a fill function like fill
or fill_keep
to render it.translate
, rotate
, or scale
can be applied to the Sdf2d
context to adjust the position and orientation of the box as needed.