The move_to function sets the starting point of a new path in the Sdf2d drawing context. It updates the current position to the specified coordinates (x, y) without drawing a line from the previous position. This is commonly used when beginning a new shape or repositioning the drawing cursor without connecting it to the previous path.
self (inout): A reference to the Sdf2d instance. The function modifies the start_pos and last_pos fields of self to the new position (x, y).
x (float): The x-coordinate of the new starting point.
y (float): The y-coordinate of the new starting point.
Sdf2d context to reflect the new starting position.In this example:
Initialize Drawing Context: We create an Sdf2d instance for drawing, scaled to the current rectangle size.
Start New Path: Use sdf.move_to(50.0, 20.0) to set the starting point of the path at (50.0, 20.0).
Draw Lines: Draw lines to two other points using sdf.line_to, forming the sides of a triangle.
Close Path: Call sdf.close_path() to draw a line back to the starting point, completing the triangle.
Fill Shape: Fill the shape with red color using sdf.fill(#f00).
Result: Return sdf.result, which contains the final rendered image.
Starting Point: The move_to function moves the drawing cursor without creating a line, essentially lifting the pen up and moving to a new location.
Path Construction: Combining move_to, line_to, and close_path allows you to define complex shapes by specifying their vertices.
State Update: After calling move_to, both start_pos and last_pos are updated to the new coordinates, preparing for subsequent drawing commands.