The rect
function draws a rectangle within the Sdf2d
drawing context. The rectangle is defined by its position and dimensions, with the origin at the lower-left corner.
Sdf2d
instance. The function modifies the internal state of self
to include the rectangle shape.float
): The x-coordinate of the lower-left corner of the rectangle.float
): The y-coordinate of the lower-left corner of the rectangle.float
): The width of the rectangle.float
): The height of the rectangle.self
to represent the rectangle.In this example:
Sdf2d
context using the current position (self.pos
) and size (self.rect_size
) of the viewport.rect
function to draw a rectangle starting at position (10.0, 10.0)
with a width of 80.0
units and a height of 60.0
units.sdf.fill(#f00)
.PI * 0.25
radians) around the point (50.0, 40.0)
, which is the center of the rectangle. This demonstrates how transformations can be applied to shapes.sdf.result
, which contains the final rendered color after all drawing operations.(x, y)
. The width (w
) and height (h
) extend the rectangle to the right and upwards.translate
, rotate
, or scale
to the Sdf2d
context to adjust the position and orientation of the rectangle.rect
before applying fills or other drawing operations. The fill
function renders the shape onto the context.