The box_y
function draws a rectangle within the Sdf2d
drawing context, allowing you to specify different corner radii for the top and bottom sides. This enables the creation of rectangles with asymmetric rounded corners along the vertical 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 top corners (top-left and top-right).float
): The radius of the bottom corners (bottom-left 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_y
to draw a rectangle starting at position (10.0, 10.0)
with a width of 80.0
units and a height of 100.0
units. The top corners (r_top
) have a radius of 15.0
, and the bottom corners (r_bottom
) have a radius of 5.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_y
, use a fill function like fill
or fill_keep
to render it.translate
, rotate
, or scale
to the Sdf2d
context to adjust the position and orientation of the box as needed.