|
| 1 | +""" |
| 2 | +
|
| 3 | +raylib [shapes] example - Lines Bezier |
| 4 | +
|
| 5 | +""" |
| 6 | + |
| 7 | +from pyray import * |
| 8 | +from raylib.colors import ( |
| 9 | + RAYWHITE, |
| 10 | + GRAY, |
| 11 | + RED |
| 12 | +) |
| 13 | + |
| 14 | + |
| 15 | +# ------------------------------------------------------------------------------------ |
| 16 | +# Program main entry point |
| 17 | +# ------------------------------------------------------------------------------------ |
| 18 | +def main(): |
| 19 | + # Initialization |
| 20 | + screenWidth = 800 |
| 21 | + screenHeight = 450 |
| 22 | + |
| 23 | + set_config_flags(ConfigFlags.FLAG_MSAA_4X_HINT) |
| 24 | + init_window(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines") |
| 25 | + |
| 26 | + start = Vector2(0, 0) |
| 27 | + end = Vector2(screenWidth, screenHeight) |
| 28 | + |
| 29 | + set_target_fps(60) # Set our game to run at 60 frames-per-second |
| 30 | + # ------------------------------------------------------------------------------------- |
| 31 | + |
| 32 | + # Main game loop |
| 33 | + while not window_should_close(): # Detect window close button or ESC key |
| 34 | + # Update |
| 35 | + # ---------------------------------------------------------------------------------- |
| 36 | + if is_mouse_button_down(MouseButton.MOUSE_BUTTON_LEFT): start = get_mouse_position() |
| 37 | + if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT): end = get_mouse_position() |
| 38 | + # ---------------------------------------------------------------------------------- |
| 39 | + |
| 40 | + # Draw |
| 41 | + # ---------------------------------------------------------------------------------- |
| 42 | + begin_drawing() |
| 43 | + |
| 44 | + clear_background(RAYWHITE) |
| 45 | + |
| 46 | + draw_text("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY) |
| 47 | + |
| 48 | + draw_line_bezier(start, end, 2.0, RED) |
| 49 | + |
| 50 | + end_drawing() |
| 51 | + # ---------------------------------------------------------------------------------- |
| 52 | + |
| 53 | + # De-Initialization |
| 54 | + # ---------------------------------------------------------------------------------- |
| 55 | + close_window() # Close window and OpenGL context |
| 56 | + # ---------------------------------------------------------------------------------- |
| 57 | + |
| 58 | +if __name__ == '__main__': |
| 59 | + main() |
0 commit comments