1 | /******************************************************************************************* |
2 | * |
3 | * raylib [shapes] example - Cubic-bezier lines |
4 | * |
5 | * This example has been created using raylib 1.7 (www.raylib.com) |
6 | * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) |
7 | * |
8 | * Copyright (c) 2017 Ramon Santamaria (@raysan5) |
9 | * |
10 | ********************************************************************************************/ |
11 | |
12 | #include "raylib.h" |
13 | |
14 | int main(void) |
15 | { |
16 | // Initialization |
17 | //-------------------------------------------------------------------------------------- |
18 | const int screenWidth = 800; |
19 | const int screenHeight = 450; |
20 | |
21 | SetConfigFlags(FLAG_MSAA_4X_HINT); |
22 | InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines" ); |
23 | |
24 | Vector2 start = { 0, 0 }; |
25 | Vector2 end = { screenWidth, screenHeight }; |
26 | |
27 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second |
28 | //-------------------------------------------------------------------------------------- |
29 | |
30 | // Main game loop |
31 | while (!WindowShouldClose()) // Detect window close button or ESC key |
32 | { |
33 | // Update |
34 | //---------------------------------------------------------------------------------- |
35 | if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition(); |
36 | else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition(); |
37 | //---------------------------------------------------------------------------------- |
38 | |
39 | // Draw |
40 | //---------------------------------------------------------------------------------- |
41 | BeginDrawing(); |
42 | |
43 | ClearBackground(RAYWHITE); |
44 | |
45 | DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS" , 15, 20, 20, GRAY); |
46 | |
47 | DrawLineBezier(start, end, 2.0f, RED); |
48 | |
49 | EndDrawing(); |
50 | //---------------------------------------------------------------------------------- |
51 | } |
52 | |
53 | // De-Initialization |
54 | //-------------------------------------------------------------------------------------- |
55 | CloseWindow(); // Close window and OpenGL context |
56 | //-------------------------------------------------------------------------------------- |
57 | |
58 | return 0; |
59 | } |
60 | |