From 3836c7ed93ae0f8dd45f53bfeb68b7596ed93de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D7=93=D7=95=D7=A8=20=D7=A9=D7=A4=D7=99=D7=A8=D7=90?= Date: Tue, 20 Sep 2022 21:19:30 +0300 Subject: [PATCH] adding shapes lines bezier example --- examples/shapes/shapes_lines_bezier.py | 59 ++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 examples/shapes/shapes_lines_bezier.py diff --git a/examples/shapes/shapes_lines_bezier.py b/examples/shapes/shapes_lines_bezier.py new file mode 100644 index 0000000..7b40d49 --- /dev/null +++ b/examples/shapes/shapes_lines_bezier.py @@ -0,0 +1,59 @@ +""" + +raylib [shapes] example - Lines Bezier + +""" + +from pyray import * +from raylib.colors import ( + RAYWHITE, + GRAY, + RED +) + + +# ------------------------------------------------------------------------------------ +# Program main entry point +# ------------------------------------------------------------------------------------ +def main(): + # Initialization + screenWidth = 800 + screenHeight = 450 + + set_config_flags(ConfigFlags.FLAG_MSAA_4X_HINT) + init_window(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines") + + start = Vector2(0, 0) + end = Vector2(screenWidth, screenHeight) + + set_target_fps(60) # Set our game to run at 60 frames-per-second + # ------------------------------------------------------------------------------------- + + # Main game loop + while not window_should_close(): # Detect window close button or ESC key + # Update + # ---------------------------------------------------------------------------------- + if is_mouse_button_down(MouseButton.MOUSE_BUTTON_LEFT): start = get_mouse_position() + if is_mouse_button_down(MouseButton.MOUSE_BUTTON_RIGHT): end = get_mouse_position() + # ---------------------------------------------------------------------------------- + + # Draw + # ---------------------------------------------------------------------------------- + begin_drawing() + + clear_background(RAYWHITE) + + draw_text("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY) + + draw_line_bezier(start, end, 2.0, RED) + + end_drawing() + # ---------------------------------------------------------------------------------- + + # De-Initialization + # ---------------------------------------------------------------------------------- + close_window() # Close window and OpenGL context + # ---------------------------------------------------------------------------------- + +if __name__ == '__main__': + main()