The box_all function draws a rectangle within the Sdf2d drawing context, allowing each corner to have an individual radius. This enables the creation of rectangles with asymmetrical rounded corners.
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-left corner.float): The radius of the top-right corner.float): The radius of the bottom-right corner.float): The radius of the bottom-left corner.self to represent the box with the specified rounded corners.In this example:
Sdf2d drawing context using the current position (self.pos) and size (self.rect_size) of the viewport.box_all to draw a rectangle starting at position (10.0, 10.0) with a width and height of 80.0. Each corner has a different corner radius:
r_left_top): 0.0 (sharp corner)r_right_top): 10.0r_right_bottom): 20.0r_left_bottom): 5.0sdf.fill(#f00).sdf.result, which contains the final rendered color.(x, y). The width (w) extends the box to the right, and the height (h) extends it upwards.fill or fill_keep after defining the shape to render it.translate, rotate, or scale to the Sdf2d context before or after drawing the shape to position and orient it as needed.