The hline function draws a horizontal line within the Sdf2d drawing context at a specified y-coordinate and with a specified half-thickness. This function is useful for adding horizontal lines or dividers in your graphics or UI elements.
Sdf2d instance. The function modifies the internal state of self to include the horizontal line shape.float): The y-coordinate of the center of the horizontal line.float): The half-thickness of the line. The total thickness of the line will be 2 * h.self to represent the horizontal line.In this example:
Sdf2d context using the current position (self.pos) and size (self.rect_size) of the viewport.sdf.hline to draw a horizontal line centered at y = 50.0 with a half-thickness of 2.0. This results in a line that is 4.0 units thick.sdf.fill(#f00). The color #f00 is shorthand for red in hexadecimal notation.PI * 0.5 radians) around the point (50.0, 50.0). This demonstrates how transformations can be applied to the drawing.sdf.result, which contains the final rendered color after all drawing operations.h parameter changes the thickness of the line. A larger h results in a thicker line.y coordinate.translate, rotate, or scale can be applied to the Sdf2d context to manipulate the position and orientation of the line.fill or fill_keep after defining the shape to render it.e