The circle
function draws a circle within the Sdf2d
drawing context. The circle is defined by its center coordinates and radius.
Sdf2d
instance. The function modifies the internal state of self
to include the circle shape.float
): The x-coordinate of the center of the circle.float
): The y-coordinate of the center of the circle.float
): The radius of the circle.self
to represent the circle.In this example:
Sdf2d
context using the current position (self.pos
) and the size of the rectangle (self.rect_size
), which represents the viewport area for drawing.circle
function to draw a circle centered at (50.0, 50.0)
with a radius of 40.0
.sdf.fill(#f00)
. The #f00
is a shorthand for the color red in hexadecimal notation.PI * 0.25
radians) around the center point (50.0, 50.0)
. This affects all subsequent drawing operations and transformations applied to sdf
.sdf.result
, which contains the final rendered color after all drawing operations.(x, y)
. Adjust these values to position the circle within your drawing area.r
parameter defines the size of the circle. A larger radius creates a bigger circle.rotate
function is used here to rotate the drawing. Other transformations like translate
and scale
can also be applied to manipulate the drawing context.circle
) before applying fills or other drawing operations. Calling fill
or fill_keep
renders the shape onto the context.