The close_path
function completes the current path by drawing a line from the last point back to the starting point. This effectively closes the shape, ensuring that it is a continuous loop. It's commonly used when you need to create closed shapes like polygons.
Sdf2d
instance. The function updates the internal state of self
by connecting the current position back to the starting position of the path.Sdf2d
context to close the current path.In this example:
Sdf2d
drawing context using the current position (self.pos
) and size (self.rect_size
) of the viewport.(50.0, 10.0)
using sdf.move_to
.(90.0, 80.0)
using sdf.line_to(90.0, 80.0)
.(10.0, 80.0)
using sdf.line_to(10.0, 80.0)
.sdf.close_path()
to draw a line from the current point back to the starting point (50.0, 10.0)
, completing the triangle.sdf.fill(#f00)
.sdf.result
, which contains the final rendered color after all drawing operations.move_to
, line_to
, and close_path
allows you to construct complex shapes by defining their outlines point by point.close_path
function uses the start_pos
and last_pos
internally to determine where to draw the closing line.close_path
before applying fills or strokes to render the shape correctly.