raylib/examples/shapes/shapes_lines_bezier.c

60 lines
2.2 KiB
C
Raw Normal View History

2017-04-14 16:37:50 +03:00
/*******************************************************************************************
*
* raylib [shapes] example - Cubic-bezier lines
*
* This example has been created using raylib 1.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2017 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
2019-05-20 17:36:42 +03:00
int main(void)
2017-04-14 16:37:50 +03:00
{
// Initialization
//--------------------------------------------------------------------------------------
2019-05-20 17:36:42 +03:00
const int screenWidth = 800;
const int screenHeight = 450;
2017-04-14 16:37:50 +03:00
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines");
2019-05-20 17:36:42 +03:00
2017-04-14 16:37:50 +03:00
Vector2 start = { 0, 0 };
Vector2 end = { screenWidth, screenHeight };
2019-05-20 17:36:42 +03:00
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
2017-04-14 16:37:50 +03:00
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) start = GetMousePosition();
else if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) end = GetMousePosition();
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
2019-05-20 17:36:42 +03:00
2017-04-14 16:37:50 +03:00
DrawText("USE MOUSE LEFT-RIGHT CLICK to DEFINE LINE START and END POINTS", 15, 20, 20, GRAY);
DrawLineBezier(start, end, 2.0f, RED);
2019-05-20 17:36:42 +03:00
2017-04-14 16:37:50 +03:00
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
2019-05-20 17:36:42 +03:00
//--------------------------------------------------------------------------------------
2017-04-14 16:37:50 +03:00
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}