examples review
Redesigns, deletes and renames Also noted authors propertly on contributed examples
| @@ -1,6 +1,6 @@ | |||||||
| /*******************************************************************************************
 | /*******************************************************************************************
 | ||||||
| * | * | ||||||
| *   raylib [core] example - Initialize 3d mode | *   raylib [core] example - Initialize 3d camera mode | ||||||
| * | * | ||||||
| *   This example has been created using raylib 1.0 (www.raylib.com) | *   This example has been created using raylib 1.0 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| @@ -15,13 +15,13 @@ int main() | |||||||
| { | { | ||||||
|     // Initialization
 |     // Initialization
 | ||||||
|     //--------------------------------------------------------------------------------------
 |     //--------------------------------------------------------------------------------------
 | ||||||
|     int screenWidth = 800; |     const int screenWidth = 800; | ||||||
|     int screenHeight = 450; |     const int screenHeight = 450; | ||||||
| 
 | 
 | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode"); |     InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera mode"); | ||||||
| 
 | 
 | ||||||
|     // Define the camera to look into our 3d world
 |     // Define the camera to look into our 3d world
 | ||||||
|     Camera3D camera; |     Camera3D camera = { 0 }; | ||||||
|     camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };  // Camera position
 |     camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };  // Camera position
 | ||||||
|     camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
 |     camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
 | ||||||
|     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
 |     camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
 | ||||||
| Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB | 
| @@ -1,94 +0,0 @@ | |||||||
| /******************************************************************************************* |  | ||||||
| * |  | ||||||
| *   raylib [core] example - Color selection by mouse (collision detection) |  | ||||||
| * |  | ||||||
| *   This example has been created using raylib 1.0 (www.raylib.com) |  | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) |  | ||||||
| * |  | ||||||
| *   Copyright (c) 2014 Ramon Santamaria (@raysan5) |  | ||||||
| * |  | ||||||
| ********************************************************************************************/ |  | ||||||
|  |  | ||||||
| #include "raylib.h" |  | ||||||
|  |  | ||||||
| int main() |  | ||||||
| { |  | ||||||
|     // Initialization |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|     int screenWidth = 800; |  | ||||||
|     int screenHeight = 450; |  | ||||||
|  |  | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [core] example - color selection (collision detection)"); |  | ||||||
|  |  | ||||||
|     Color colors[21] = { DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, |  | ||||||
|                          GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, |  | ||||||
|                          GREEN, SKYBLUE, PURPLE, BEIGE }; |  | ||||||
|  |  | ||||||
|     Rectangle colorsRecs[21];             // Rectangles array |  | ||||||
|  |  | ||||||
|     // Fills colorsRecs data (for every rectangle) |  | ||||||
|     for (int i = 0; i < 21; i++) |  | ||||||
|     { |  | ||||||
|         colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7); |  | ||||||
|         colorsRecs[i].y = 60 + 100*(i/7) + 10*(i/7); |  | ||||||
|         colorsRecs[i].width = 100; |  | ||||||
|         colorsRecs[i].height = 100; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     bool selected[21] = { false };  // Selected rectangles indicator |  | ||||||
|  |  | ||||||
|     Vector2 mousePoint; |  | ||||||
|  |  | ||||||
|     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|     // Main game loop |  | ||||||
|     while (!WindowShouldClose())    // Detect window close button or ESC key |  | ||||||
|     { |  | ||||||
|         // Update |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|         mousePoint = GetMousePosition(); |  | ||||||
|  |  | ||||||
|         for (int i = 0; i < 21; i++)    // Iterate along all the rectangles |  | ||||||
|         { |  | ||||||
|             if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) |  | ||||||
|             { |  | ||||||
|                 colors[i].a = 120; |  | ||||||
|  |  | ||||||
|                 if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) selected[i] = !selected[i]; |  | ||||||
|             } |  | ||||||
|             else colors[i].a = 255; |  | ||||||
|         } |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|         // Draw |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|         BeginDrawing(); |  | ||||||
|  |  | ||||||
|             ClearBackground(RAYWHITE); |  | ||||||
|  |  | ||||||
|             for (int i = 0; i < 21; i++)    // Draw all rectangles |  | ||||||
|             { |  | ||||||
|                 DrawRectangleRec(colorsRecs[i], colors[i]); |  | ||||||
|  |  | ||||||
|                 // Draw four rectangles around selected rectangle |  | ||||||
|                 if (selected[i]) |  | ||||||
|                 { |  | ||||||
|                     DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 100, 10, RAYWHITE);        // Square top rectangle |  | ||||||
|                     DrawRectangle(colorsRecs[i].x, colorsRecs[i].y, 10, 100, RAYWHITE);        // Square left rectangle |  | ||||||
|                     DrawRectangle(colorsRecs[i].x + 90, colorsRecs[i].y, 10, 100, RAYWHITE);   // Square right rectangle |  | ||||||
|                     DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + 90, 100, 10, RAYWHITE);   // Square bottom rectangle |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|  |  | ||||||
|         EndDrawing(); |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // De-Initialization |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|     CloseWindow();                // Close window and OpenGL context |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| Before Width: | Height: | Size: 14 KiB | 
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.1 (www.raylib.com) | *   This example has been created using raylib 2.1 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2018 Ramon Santamaria (@raysan5) and Pablo Marcos Oltra (@pamarcos) | *   Example contributed by Pablo Marcos Oltra (@pamarcos) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Pablo Marcos Oltra (@pamarcos) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| /*******************************************************************************************
 | /*******************************************************************************************
 | ||||||
| * | * | ||||||
| *   raylib [core] example - Gestures Detection | *   raylib [core] example - Input Gestures Detection | ||||||
| * | * | ||||||
| *   This example has been created using raylib 1.4 (www.raylib.com) | *   This example has been created using raylib 1.4 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| @@ -21,7 +21,7 @@ int main() | |||||||
|     int screenWidth = 800; |     int screenWidth = 800; | ||||||
|     int screenHeight = 450; |     int screenHeight = 450; | ||||||
|      |      | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection"); |     InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures"); | ||||||
|      |      | ||||||
|     Vector2 touchPosition = { 0, 0 }; |     Vector2 touchPosition = { 0, 0 }; | ||||||
|     Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 }; |     Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 }; | ||||||
| Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB | 
| @@ -1,6 +1,6 @@ | |||||||
| /*******************************************************************************************
 | /*******************************************************************************************
 | ||||||
| * | * | ||||||
| *   raylib [core] examples - Mouse wheel | *   raylib [core] examples - Mouse wheel input | ||||||
| * | * | ||||||
| *   This test has been created using raylib 1.1 (www.raylib.com) | *   This test has been created using raylib 1.1 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| @@ -18,7 +18,7 @@ int main() | |||||||
|     int screenWidth = 800; |     int screenWidth = 800; | ||||||
|     int screenHeight = 450; |     int screenHeight = 450; | ||||||
| 
 | 
 | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse wheel"); |     InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel"); | ||||||
| 
 | 
 | ||||||
|     int boxPositionY = screenHeight/2 - 40; |     int boxPositionY = screenHeight/2 - 40; | ||||||
|     int scrollSpeed = 4;            // Scrolling speed in pixels
 |     int scrollSpeed = 4;            // Scrolling speed in pixels
 | ||||||
| Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB | 
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.1 (www.raylib.com) | *   This example has been created using raylib 2.1 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2014-2019 Berni and Ramon Santamaria (@raysan5)  | *   Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2019 Berni (@Berni8k) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -15,10 +15,13 @@ | |||||||
| #include "raylib.h" | #include "raylib.h" | ||||||
|  |  | ||||||
| #include "pthread.h"                        // POSIX style threads management | #include "pthread.h"                        // POSIX style threads management | ||||||
| #include <stdatomic.h> |  | ||||||
|  |  | ||||||
| #include <time.h>                           // Required for clock() function | #include <stdatomic.h>                      // C11 atomic data types | ||||||
|  |  | ||||||
|  | #include <time.h>                           // Required for: clock() | ||||||
|  |  | ||||||
|  | // Using C11 atomics for synchronization | ||||||
|  | // NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization | ||||||
| static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator | static atomic_bool dataLoaded = ATOMIC_VAR_INIT(false); // Data Loaded completion indicator | ||||||
| static void *LoadDataThread(void *arg);     // Loading data thread function declaration | static void *LoadDataThread(void *arg);     // Loading data thread function declaration | ||||||
|  |  | ||||||
| @@ -49,6 +52,7 @@ int main() | |||||||
|         switch (state) |         switch (state) | ||||||
|         { |         { | ||||||
|             case STATE_WAITING: |             case STATE_WAITING: | ||||||
|  |             { | ||||||
|                 if (IsKeyPressed(KEY_ENTER)) |                 if (IsKeyPressed(KEY_ENTER)) | ||||||
|                 { |                 { | ||||||
|                     int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL); |                     int error = pthread_create(&threadId, NULL, &LoadDataThread, NULL); | ||||||
| @@ -57,16 +61,18 @@ int main() | |||||||
|  |  | ||||||
|                     state = STATE_LOADING; |                     state = STATE_LOADING; | ||||||
|                 } |                 } | ||||||
|             break; |             } break; | ||||||
|             case STATE_LOADING: |             case STATE_LOADING: | ||||||
|  |             { | ||||||
|                 framesCounter++; |                 framesCounter++; | ||||||
|                 if (atomic_load(&dataLoaded)) |                 if (atomic_load(&dataLoaded)) | ||||||
|                 { |                 { | ||||||
|                     framesCounter = 0; |                     framesCounter = 0; | ||||||
|                     state = STATE_FINISHED; |                     state = STATE_FINISHED; | ||||||
|                 } |                 } | ||||||
|             break; |             } break; | ||||||
|             case STATE_FINISHED: |             case STATE_FINISHED: | ||||||
|  |             { | ||||||
|                 if (IsKeyPressed(KEY_ENTER)) |                 if (IsKeyPressed(KEY_ENTER)) | ||||||
|                 { |                 { | ||||||
|                     // Reset everything to launch again |                     // Reset everything to launch again | ||||||
| @@ -74,7 +80,8 @@ int main() | |||||||
|                     dataProgress = 0; |                     dataProgress = 0; | ||||||
|                     state = STATE_WAITING; |                     state = STATE_WAITING; | ||||||
|                 } |                 } | ||||||
|             break; |             } break; | ||||||
|  |             default: break; | ||||||
|         } |         } | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
| @@ -84,19 +91,22 @@ int main() | |||||||
|  |  | ||||||
|             ClearBackground(RAYWHITE); |             ClearBackground(RAYWHITE); | ||||||
|              |              | ||||||
|             switch(state) { |             switch (state)  | ||||||
|             case STATE_WAITING: |             { | ||||||
|                 DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); |                 case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break; | ||||||
|                 break; |  | ||||||
|                 case STATE_LOADING: |                 case STATE_LOADING: | ||||||
|  |                 { | ||||||
|                     DrawRectangle(150, 200, dataProgress, 60, SKYBLUE); |                     DrawRectangle(150, 200, dataProgress, 60, SKYBLUE); | ||||||
|                 if ((framesCounter/15)%2) |                     if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); | ||||||
|                     DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE); |                      | ||||||
|                 break; |                 } break; | ||||||
|                 case STATE_FINISHED: |                 case STATE_FINISHED: | ||||||
|  |                 { | ||||||
|                     DrawRectangle(150, 200, 500, 60, LIME); |                     DrawRectangle(150, 200, 500, 60, LIME); | ||||||
|                     DrawText("DATA LOADED!", 250, 210, 40, GREEN); |                     DrawText("DATA LOADED!", 250, 210, 40, GREEN); | ||||||
|                 break; |                      | ||||||
|  |                 } break; | ||||||
|  |                 default: break; | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             DrawRectangleLines(150, 200, 500, 60, DARKGRAY); |             DrawRectangleLines(150, 200, 500, 60, DARKGRAY); | ||||||
|   | |||||||
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Anata and Ramon Santamaria (@raysan5) | *   Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
| 
 | 
 | ||||||
| Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB | 
| @@ -4,10 +4,12 @@ | |||||||
| * | * | ||||||
| *   This program is heavily based on the geometric objects example | *   This program is heavily based on the geometric objects example | ||||||
| * | * | ||||||
| *   This example has been created using raylib 1.9.7 (www.raylib.com) | *   This example has been created using raylib 2.0 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2018 Max Danielsson & Ramon Santamaria (@raysan5) | *   Example contributed by Max Danielsson (@autious) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Max Danielsson (@autious) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,9 +5,9 @@ | |||||||
| *   This example has been created using raylib 1.8 (www.raylib.com) | *   This example has been created using raylib 1.8 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Example based on Berni work on Raspberry Pi. | *   Example contributed by Berni (@Berni8k) and reviewed by Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| *   Copyright (c) 2017 Ramon Santamaria (@raysan5) | *   Copyright (c) 2017 Berni (@Berni8k) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| /******************************************************************************************* | /******************************************************************************************* | ||||||
| * | * | ||||||
| *   raylib [shaders] example - Render julia sets using a shader. | *   raylib [shaders] example - julia sets | ||||||
| * | * | ||||||
| *   NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, | *   NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, | ||||||
| *         OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. | *         OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. | ||||||
| @@ -10,73 +10,68 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Author: eggmund (https://github.com/eggmund) | *   Example contributed by eggmund (@eggmund) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2019 eggmund (@eggmund) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
| #include "raylib.h" | #include "raylib.h" | ||||||
| #include <string.h> // For memcpy |  | ||||||
|  |  | ||||||
| // Speed when using auto | #include "raymath.h" | ||||||
| const float AUTO_SPEED = 0.0005; |  | ||||||
|  |  | ||||||
| // A few good julia sets | // A few good julia sets | ||||||
| const float POINTS_OF_INTEREST[6][2] = | const float POINTS_OF_INTEREST[6][2] = | ||||||
| {  | {  | ||||||
|     {-0.348827, 0.607167}, |     { -0.348827, 0.607167 }, | ||||||
|     {-0.786268, 0.169728}, |     { -0.786268, 0.169728 }, | ||||||
|     {-0.8, 0.156}, |     { -0.8, 0.156 }, | ||||||
|     {0.285, 0.0}, |     { 0.285, 0.0 }, | ||||||
|     {-0.835, -0.2321}, |     { -0.835, -0.2321 }, | ||||||
|     {-0.70176, -0.3842}, |     { -0.70176, -0.3842 }, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| int main() | int main() | ||||||
| { | { | ||||||
|     // Initialization |     // Initialization | ||||||
|     //-------------------------------------------------------------------------------------- |     //-------------------------------------------------------------------------------------- | ||||||
|     int screenWidth = 1280; |     const int screenWidth = 800; | ||||||
|     int screenHeight = 720; |     const int screenHeight = 450; | ||||||
|  |  | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [shaders] example - julia set renderer"); |     InitWindow(screenWidth, screenHeight, "raylib [shaders] example - julia sets"); | ||||||
|  |  | ||||||
|     // If julia set is rendered for this frame. |  | ||||||
|     bool rendered = false; |  | ||||||
|  |  | ||||||
|     bool showControls = true; |  | ||||||
|  |  | ||||||
|     // Multiplier of speed to change c value. Set to 3 to start off with. |  | ||||||
|     int incrementSpeed = 3; |  | ||||||
|  |  | ||||||
|     // Offset and zoom to draw the julia set at. (centered on screen and 1.6 times smaller) |  | ||||||
|     float offset[2] = { -(float)screenWidth/2, -(float)screenHeight/2 };  |  | ||||||
|     float zoom = 1.6; |  | ||||||
|  |  | ||||||
|     // c constant to use in z^2 + c |  | ||||||
|     float c[2]; |  | ||||||
|     // Copy a point of interest into the c variable. 4 bytes per float (32 bits). |  | ||||||
|     memcpy(c, &POINTS_OF_INTEREST[0], 8); |  | ||||||
|  |  | ||||||
|     // Load julia set shader |     // Load julia set shader | ||||||
|     // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader |     // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader | ||||||
|     Shader shader = LoadShader(0, "resources/shaders/glsl330/julia_shader.fs"); |     Shader shader = LoadShader(0, "resources/shaders/glsl330/julia_shader.fs"); | ||||||
|      |      | ||||||
|     // Get variable (uniform) location on the shader to connect with the program |     // c constant to use in z^2 + c | ||||||
|  |     float c[2] = { POINTS_OF_INTEREST[0][0], POINTS_OF_INTEREST[0][1] }; | ||||||
|  |      | ||||||
|  |     // Offset and zoom to draw the julia set at. (centered on screen and 1.6 times smaller) | ||||||
|  |     float offset[2] = { -(float)screenWidth/2, -(float)screenHeight/2 };  | ||||||
|  |     float zoom = 1.6f; | ||||||
|  |      | ||||||
|  |     // Get variable (uniform) locations on the shader to connect with the program | ||||||
|     // NOTE: If uniform variable could not be found in the shader, function returns -1 |     // NOTE: If uniform variable could not be found in the shader, function returns -1 | ||||||
|     // The location of c will be stored since we will need to change this whenever c changes |  | ||||||
|     int cLoc = GetShaderLocation(shader, "c"); |     int cLoc = GetShaderLocation(shader, "c"); | ||||||
|  |     int zoomLoc = GetShaderLocation(shader, "zoom"); | ||||||
|  |     int offsetLoc = GetShaderLocation(shader, "offset"); | ||||||
|  |  | ||||||
|     // Tell the shader what the screen dimensions, zoom, offset and c are |     // Tell the shader what the screen dimensions, zoom, offset and c are | ||||||
|     float screenDims[2] = { (float)screenWidth, (float)screenHeight }; |     float screenDims[2] = { (float)screenWidth, (float)screenHeight }; | ||||||
|     SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2); |     SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2); | ||||||
|     SetShaderValue(shader, GetShaderLocation(shader, "zoom"), &zoom, UNIFORM_FLOAT); |  | ||||||
|     SetShaderValue(shader, GetShaderLocation(shader, "offset"), offset, UNIFORM_VEC2); |  | ||||||
|      |      | ||||||
|     SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); |     SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); | ||||||
|  |     SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT); | ||||||
|  |     SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2); | ||||||
|  |  | ||||||
|     // Create a RenderTexture2D to be used for render to texture |     // Create a RenderTexture2D to be used for render to texture | ||||||
|     RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); |     RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); | ||||||
|      |      | ||||||
|  |     int incrementSpeed = 3;     // Multiplier of speed to change c value | ||||||
|  |     bool showControls = true;   // Show controls | ||||||
|  |     bool pause = false;         // Pause animation | ||||||
|  |  | ||||||
|     SetTargetFPS(60);                       // Set the window to run at 60 frames-per-second |     SetTargetFPS(60);                       // Set the window to run at 60 frames-per-second | ||||||
|     //-------------------------------------------------------------------------------------- |     //-------------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
| @@ -86,78 +81,55 @@ int main() | |||||||
|         // Update |         // Update | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|         // Get input |         // Press [1 - 6] to reset c to a point of interest | ||||||
|         //---------------------------------------------------------------------------------- |         if (IsKeyPressed(KEY_ONE) ||  | ||||||
|  |             IsKeyPressed(KEY_TWO) ||  | ||||||
|  |             IsKeyPressed(KEY_THREE) ||  | ||||||
|  |             IsKeyPressed(KEY_FOUR) ||  | ||||||
|  |             IsKeyPressed(KEY_FIVE) ||  | ||||||
|  |             IsKeyPressed(KEY_SIX)) | ||||||
|  |         { | ||||||
|  |             if (IsKeyPressed(KEY_ONE)) c[0] = POINTS_OF_INTEREST[0][0], c[1] = POINTS_OF_INTEREST[0][1]; | ||||||
|  |             else if (IsKeyPressed(KEY_TWO)) c[0] = POINTS_OF_INTEREST[1][0], c[1] = POINTS_OF_INTEREST[1][1]; | ||||||
|  |             else if (IsKeyPressed(KEY_THREE)) c[0] = POINTS_OF_INTEREST[2][0], c[1] = POINTS_OF_INTEREST[2][1]; | ||||||
|  |             else if (IsKeyPressed(KEY_FOUR)) c[0] = POINTS_OF_INTEREST[3][0], c[1] = POINTS_OF_INTEREST[3][1]; | ||||||
|  |             else if (IsKeyPressed(KEY_FIVE)) c[0] = POINTS_OF_INTEREST[4][0], c[1] = POINTS_OF_INTEREST[4][1]; | ||||||
|  |             else if (IsKeyPressed(KEY_SIX)) c[0] = POINTS_OF_INTEREST[5][0], c[1] = POINTS_OF_INTEREST[5][1]; | ||||||
|  |  | ||||||
|         // Press 1 - 6 to reset c to a point of interest. |  | ||||||
|         if (IsKeyPressed(KEY_ONE) || IsKeyPressed(KEY_TWO) || IsKeyPressed(KEY_THREE) || IsKeyPressed(KEY_FOUR) || IsKeyPressed(KEY_FIVE) || IsKeyPressed(KEY_SIX)) |  | ||||||
|         { |  | ||||||
|             if (IsKeyPressed(KEY_ONE)) |  | ||||||
|             { |  | ||||||
|                 memcpy(c, &POINTS_OF_INTEREST[0], 8); |  | ||||||
|             } |  | ||||||
|             else if (IsKeyPressed(KEY_TWO)) |  | ||||||
|             { |  | ||||||
|                 memcpy(c, &POINTS_OF_INTEREST[1], 8); |  | ||||||
|             } |  | ||||||
|             else if (IsKeyPressed(KEY_THREE)) |  | ||||||
|             { |  | ||||||
|                 memcpy(c, &POINTS_OF_INTEREST[2], 8); |  | ||||||
|             } |  | ||||||
|             else if (IsKeyPressed(KEY_FOUR)) |  | ||||||
|             { |  | ||||||
|                 memcpy(c, &POINTS_OF_INTEREST[3], 8); |  | ||||||
|             } |  | ||||||
|             else if (IsKeyPressed(KEY_FIVE)) |  | ||||||
|             { |  | ||||||
|                 memcpy(c, &POINTS_OF_INTEREST[4], 8); |  | ||||||
|             } |  | ||||||
|             else if (IsKeyPressed(KEY_SIX)) |  | ||||||
|             { |  | ||||||
|                 memcpy(c, &POINTS_OF_INTEREST[5], 8); |  | ||||||
|             } |  | ||||||
|             SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); |             SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); | ||||||
|             rendered = false;  // c value has changed, so render the set again. |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Press "r" to stop changing c |         if (IsKeyPressed(KEY_P)) pause = !pause;                 // Pause animation (c change) | ||||||
|         if (IsKeyPressed(KEY_R)) |         if (IsKeyPressed(KEY_F1)) showControls = !showControls;  // Toggle whether or not to show controls | ||||||
|  |          | ||||||
|  |         if (!pause) | ||||||
|         { |         { | ||||||
|             incrementSpeed = 0; |             if (IsKeyDown(KEY_RIGHT)) incrementSpeed++; | ||||||
|  |             else if (IsKeyDown(KEY_LEFT)) incrementSpeed--; | ||||||
|  |  | ||||||
|  |             // Use mouse wheel to change zoom | ||||||
|  |             zoom -= (float)GetMouseWheelMove()/10.f; | ||||||
|  |             SetShaderValue(shader, zoomLoc, &zoom, UNIFORM_FLOAT); | ||||||
|  |              | ||||||
|  |             // Use mouse button to change offset | ||||||
|  |             if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) | ||||||
|  |             { | ||||||
|  |                 // TODO: Logic is not correct, the idea is getting zoom focus to pointed area | ||||||
|  |                 Vector2 mousePos = GetMousePosition(); | ||||||
|  |  | ||||||
|  |                 offset[0] = mousePos.x -(float)screenWidth; | ||||||
|  |                 offset[1] = mousePos.y -(float)screenHeight; | ||||||
|  |                  | ||||||
|  |                 SetShaderValue(shader, offsetLoc, offset, UNIFORM_VEC2); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         // Toggle whether or not to show controls |             // Increment c value with time | ||||||
|         if (IsKeyPressed(KEY_H)) |             float amount = GetFrameTime()*incrementSpeed*0.0005f; | ||||||
|         { |  | ||||||
|             showControls = !showControls; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // Scroll to change c increment speed. |  | ||||||
|         int mouseMv = GetMouseWheelMove();  // Get the amount the mouse has moved this frame |  | ||||||
|         if (mouseMv != 0) |  | ||||||
|         { |  | ||||||
|             if (IsKeyDown(KEY_LEFT_SHIFT)) |  | ||||||
|             { |  | ||||||
|                 incrementSpeed += mouseMv * 10; |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 incrementSpeed += mouseMv; |  | ||||||
|             } |  | ||||||
|             rendered = false; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (incrementSpeed != 0) |  | ||||||
|         { |  | ||||||
|             float amount = GetFrameTime() * incrementSpeed * AUTO_SPEED; |  | ||||||
|             c[0] += amount; |             c[0] += amount; | ||||||
|             c[1] += amount; |             c[1] += amount; | ||||||
|  |  | ||||||
|             // Update the c value in the shader. |  | ||||||
|             SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); |             SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); | ||||||
|             rendered = false; |  | ||||||
|         } |         } | ||||||
|          |  | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|         // Draw |         // Draw | ||||||
| @@ -166,35 +138,29 @@ int main() | |||||||
|  |  | ||||||
|             ClearBackground(BLACK);         // Clear the screen of the previous frame. |             ClearBackground(BLACK);         // Clear the screen of the previous frame. | ||||||
|              |              | ||||||
|             // If the c value has changed, redraw the julia set using the shader, onto the render texture. |             // Using a render texture to draw Julia set | ||||||
|             if (!rendered) |  | ||||||
|             { |  | ||||||
|             BeginTextureMode(target);       // Enable drawing to texture |             BeginTextureMode(target);       // Enable drawing to texture | ||||||
|  |                 ClearBackground(BLACK);     // Clear the render texture | ||||||
|  |  | ||||||
|                     ClearBackground(BLACK); // Clear the last frame drawn on the texture. |                 // Draw a rectangle in shader mode | ||||||
|  |                 // NOTE: This acts as a canvas for the shader to draw on | ||||||
|                     // Draw a rectangle in shader mode. This acts as a canvas for the shader to draw on. |  | ||||||
|                 BeginShaderMode(shader); |                 BeginShaderMode(shader); | ||||||
|                         DrawRectangle(0, 0, screenWidth, screenHeight, BLACK); |                     DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLACK); | ||||||
|                 EndShaderMode(); |                 EndShaderMode(); | ||||||
|  |  | ||||||
|             EndTextureMode(); |             EndTextureMode(); | ||||||
|  |  | ||||||
|                 rendered = true; // The set is now rendered, so do not compute it again until it next changes. |             // Draw the saved texture (rendered julia set) | ||||||
|             } |             DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, Vector2Zero(), WHITE); | ||||||
|              |              | ||||||
|             // Draw the saved texture (rendered julia set). |             // Draw information | ||||||
|             DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, target.texture.height }, (Vector2){ 0, 0 }, WHITE); |             //DrawText( FormatText("cx: %f\ncy: %f\nspeed: %d", c[0], c[1], incrementSpeed), 10, 10, 10, RAYWHITE); | ||||||
|              |  | ||||||
|             // Print information. |  | ||||||
|             DrawText( FormatText("cx: %f\ncy: %f\nspeed: %d", c[0], c[1], incrementSpeed), 10, 10, 20, RAYWHITE ); |  | ||||||
|  |  | ||||||
|             if (showControls) |             if (showControls) | ||||||
|             { |             { | ||||||
|                 DrawText("Press keys 1 - 6 to change point of interest.", 10, screenHeight - 88, 20, RAYWHITE); |                 DrawText("Press keys [1 - 6] to change point of interest", 10, GetScreenHeight() - 60, 10, RAYWHITE); | ||||||
|                 DrawText("Use the scroll wheel to auto increment the c value. Hold shift while scrolling to increase speed by 10.", 10, screenHeight - 66, 20, RAYWHITE); |                 DrawText("Press KEY_LEFT | KEY_RIGHT to change speed", 10, GetScreenHeight() - 45, 10, RAYWHITE); | ||||||
|                 DrawText("Press 'r' to reset speed.", 10, screenHeight - 44, 20, RAYWHITE); |                 DrawText("Press KEY_P to pause movement animation", 10, GetScreenHeight() - 30, 10, RAYWHITE); | ||||||
|                 DrawText("Press 'h' to hide these controls.", 10, screenHeight - 22, 20, RAYWHITE); |                 DrawText("Press KEY_F1 to toggle these controls", 10, GetScreenHeight() - 15, 10, RAYWHITE); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|         EndDrawing(); |         EndDrawing(); | ||||||
|   | |||||||
| @@ -12,7 +12,9 @@ | |||||||
| *   This example has been created using raylib 2.3 (www.raylib.com) | *   This example has been created using raylib 2.3 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Ramon Santamaria (@raysan5) | *   Example contributed by Marco Lizza (@MarcoLizza) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2019 Marco Lizza (@MarcoLizza) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,6 +7,8 @@ | |||||||
| *   This example has been created using raylib 2.0 (www.raylib.com) | *   This example has been created using raylib 2.0 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
|  | *   Example contributed by Michał Ciesielski and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
| *   Copyright (c) 2019 Michał Ciesielski and Ramon Santamaria (@raysan5) | *   Copyright (c) 2019 Michał Ciesielski and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|   | |||||||
| @@ -12,7 +12,9 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Anata (creator) and Ramon Santamaria (review) (@raysan5) | *   Example contributed by Anata (@anatagawa) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2019 Anata (@anatagawa) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,26 +1,53 @@ | |||||||
| /******************************************************************************************* | /******************************************************************************************* | ||||||
| * | * | ||||||
| *   raylib [shapes] example - Draw raylib custom color palette | *   raylib [shapes] example - Colors palette | ||||||
| * | * | ||||||
| *   This example has been created using raylib 1.0 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2014 Ramon Santamaria (@raysan5) | *   Copyright (c) 2014-2019 Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
| #include "raylib.h" | #include "raylib.h" | ||||||
|  |  | ||||||
|  | #define MAX_COLORS_COUNT    21          // Number of colors available | ||||||
|  |  | ||||||
| int main() | int main() | ||||||
| { | { | ||||||
|     // Initialization |     // Initialization | ||||||
|     //-------------------------------------------------------------------------------------- |     //-------------------------------------------------------------------------------------- | ||||||
|     int screenWidth = 800; |     const int screenWidth = 800; | ||||||
|     int screenHeight = 450; |     const int screenHeight = 450; | ||||||
|  |  | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib color palette"); |     InitWindow(screenWidth, screenHeight, "raylib [shapes] example - colors palette"); | ||||||
|  |  | ||||||
|     SetTargetFPS(60); |     Color colors[MAX_COLORS_COUNT] = {  | ||||||
|  |         DARKGRAY, MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, DARKBROWN, | ||||||
|  |         GRAY, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, YELLOW, | ||||||
|  |         GREEN, SKYBLUE, PURPLE, BEIGE }; | ||||||
|  |                           | ||||||
|  |     const char *colorNames[MAX_COLORS_COUNT] = {  | ||||||
|  |         "DARKGRAY", "MAROON", "ORANGE", "DARKGREEN", "DARKBLUE", "DARKPURPLE",  | ||||||
|  |         "DARKBROWN", "GRAY", "RED", "GOLD", "LIME", "BLUE", "VIOLET", "BROWN",  | ||||||
|  |         "LIGHTGRAY", "PINK", "YELLOW", "GREEN", "SKYBLUE", "PURPLE", "BEIGE" }; | ||||||
|  |  | ||||||
|  |     Rectangle colorsRecs[MAX_COLORS_COUNT] = { 0 };     // Rectangles array | ||||||
|  |  | ||||||
|  |     // Fills colorsRecs data (for every rectangle) | ||||||
|  |     for (int i = 0; i < MAX_COLORS_COUNT; i++) | ||||||
|  |     { | ||||||
|  |         colorsRecs[i].x = 20 + 100*(i%7) + 10*(i%7); | ||||||
|  |         colorsRecs[i].y = 80 + 100*(i/7) + 10*(i/7); | ||||||
|  |         colorsRecs[i].width = 100; | ||||||
|  |         colorsRecs[i].height = 100; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     int colorState[MAX_COLORS_COUNT] = { 0 };           // Color state: 0-DEFAULT, 1-MOUSE_HOVER | ||||||
|  |  | ||||||
|  |     Vector2 mousePoint; | ||||||
|  |  | ||||||
|  |     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second | ||||||
|     //-------------------------------------------------------------------------------------- |     //-------------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|     // Main game loop |     // Main game loop | ||||||
| @@ -28,7 +55,13 @@ int main() | |||||||
|     { |     { | ||||||
|         // Update |         // Update | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|         // TODO: Update your variables here |         mousePoint = GetMousePosition(); | ||||||
|  |  | ||||||
|  |         for (int i = 0; i < MAX_COLORS_COUNT; i++) | ||||||
|  |         { | ||||||
|  |             if (CheckCollisionPointRec(mousePoint, colorsRecs[i])) colorState[i] = 1; | ||||||
|  |             else colorState[i] = 0; | ||||||
|  |         } | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|         // Draw |         // Draw | ||||||
| @@ -37,52 +70,21 @@ int main() | |||||||
|  |  | ||||||
|             ClearBackground(RAYWHITE); |             ClearBackground(RAYWHITE); | ||||||
|              |              | ||||||
|             DrawText("raylib color palette", 28, 42, 20, BLACK); |             DrawText("raylib colors palette", 28, 42, 20, BLACK); | ||||||
|  |             DrawText("press SPACE to see all colors", GetScreenWidth() - 180, GetScreenHeight() - 40, 10, GRAY); | ||||||
|  |  | ||||||
|             DrawRectangle(26, 80, 100, 100, DARKGRAY); |             for (int i = 0; i < MAX_COLORS_COUNT; i++)    // Draw all rectangles | ||||||
|             DrawRectangle(26, 188, 100, 100, GRAY); |             { | ||||||
|             DrawRectangle(26, 296, 100, 100, LIGHTGRAY); |                 DrawRectangleRec(colorsRecs[i], Fade(colors[i], colorState[i]? 0.6f : 1.0f)); | ||||||
|             DrawRectangle(134, 80, 100, 100, MAROON); |  | ||||||
|             DrawRectangle(134, 188, 100, 100, RED); |  | ||||||
|             DrawRectangle(134, 296, 100, 100, PINK); |  | ||||||
|             DrawRectangle(242, 80, 100, 100, ORANGE); |  | ||||||
|             DrawRectangle(242, 188, 100, 100, GOLD); |  | ||||||
|             DrawRectangle(242, 296, 100, 100, YELLOW); |  | ||||||
|             DrawRectangle(350, 80, 100, 100, DARKGREEN); |  | ||||||
|             DrawRectangle(350, 188, 100, 100, LIME); |  | ||||||
|             DrawRectangle(350, 296, 100, 100, GREEN); |  | ||||||
|             DrawRectangle(458, 80, 100, 100, DARKBLUE); |  | ||||||
|             DrawRectangle(458, 188, 100, 100, BLUE); |  | ||||||
|             DrawRectangle(458, 296, 100, 100, SKYBLUE); |  | ||||||
|             DrawRectangle(566, 80, 100, 100, DARKPURPLE); |  | ||||||
|             DrawRectangle(566, 188, 100, 100, VIOLET); |  | ||||||
|             DrawRectangle(566, 296, 100, 100, PURPLE); |  | ||||||
|             DrawRectangle(674, 80, 100, 100, DARKBROWN); |  | ||||||
|             DrawRectangle(674, 188, 100, 100, BROWN); |  | ||||||
|             DrawRectangle(674, 296, 100, 100, BEIGE); |  | ||||||
|                  |                  | ||||||
|  |                 if (IsKeyDown(KEY_SPACE) || colorState[i])  | ||||||
|             DrawText("DARKGRAY", 65, 166, 10, BLACK); |                 { | ||||||
|             DrawText("GRAY", 93, 274, 10, BLACK); |                     DrawRectangle(colorsRecs[i].x, colorsRecs[i].y + colorsRecs[i].height - 26, colorsRecs[i].width, 20, BLACK); | ||||||
|             DrawText("LIGHTGRAY", 61, 382, 10, BLACK); |                     DrawRectangleLinesEx(colorsRecs[i], 6, Fade(BLACK, 0.3f)); | ||||||
|             DrawText("MAROON", 186, 166, 10, BLACK); |                     DrawText(colorNames[i], colorsRecs[i].x + colorsRecs[i].width - MeasureText(colorNames[i], 10) - 12,  | ||||||
|             DrawText("RED", 208, 274, 10, BLACK); |                              colorsRecs[i].y + colorsRecs[i].height - 20, 10, colors[i]); | ||||||
|             DrawText("PINK", 204, 382, 10, BLACK); |                 } | ||||||
|             DrawText("ORANGE", 295, 166, 10, BLACK); |             } | ||||||
|             DrawText("GOLD", 310, 274, 10, BLACK); |  | ||||||
|             DrawText("YELLOW", 300, 382, 10, BLACK); |  | ||||||
|             DrawText("DARKGREEN", 382, 166, 10, BLACK); |  | ||||||
|             DrawText("LIME", 420, 274, 10, BLACK); |  | ||||||
|             DrawText("GREEN", 410, 382, 10, BLACK); |  | ||||||
|             DrawText("DARKBLUE", 498, 166, 10, BLACK); |  | ||||||
|             DrawText("BLUE", 526, 274, 10, BLACK); |  | ||||||
|             DrawText("SKYBLUE", 505, 382, 10, BLACK); |  | ||||||
|             DrawText("DARKPURPLE", 592, 166, 10, BLACK); |  | ||||||
|             DrawText("VIOLET", 621, 274, 10, BLACK); |  | ||||||
|             DrawText("PURPLE", 620, 382, 10, BLACK); |  | ||||||
|             DrawText("DARKBROWN", 705, 166, 10, BLACK); |  | ||||||
|             DrawText("BROWN", 733, 274, 10, BLACK); |  | ||||||
|             DrawText("BEIGE", 737, 382, 10, BLACK); |  | ||||||
|  |  | ||||||
|         EndDrawing(); |         EndDrawing(); | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|   | |||||||
| Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 18 KiB | 
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5) | *   Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5) | *   Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5) | *   Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2019 Demioz and Ramon Santamaria (@raysan5) | *   Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
| 
 | 
 | ||||||
| Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB | 
| @@ -20,17 +20,20 @@ int main() | |||||||
|  |  | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading"); |     InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading"); | ||||||
|  |  | ||||||
|     const char msgBm[64] = "THIS IS AN AngelCode SPRITE FONT"; |     // Define characters to draw | ||||||
|     const char msgTtf[64] = "THIS SPRITE FONT has been GENERATED from a TTF"; |     // NOTE: raylib supports UTF-8 encoding, following list is actually codified as UTF8 internally | ||||||
|  |     const char msg[256] = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI\nJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmn\nopqrstuvwxyz{|}~¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓ\nÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷\nøùúûüýþÿ"; | ||||||
|  |  | ||||||
|     // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) |     // NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required) | ||||||
|     Font fontBm = LoadFont("resources/bmfont.fnt");       // BMFont (AngelCode) |  | ||||||
|     Font fontTtf = LoadFont("resources/pixantiqua.ttf");  // TTF font |  | ||||||
|      |      | ||||||
|     Vector2 fontPosition; |     // BMFont (AngelCode) : Font data and image atlas have been generated using external program | ||||||
|  |     Font fontBm = LoadFont("resources/pixantiqua.fnt"); | ||||||
|      |      | ||||||
|     fontPosition.x = screenWidth/2 - MeasureTextEx(fontBm, msgBm, fontBm.baseSize, 0).x/2; |     // TTF font : Font data and atlas are generated directly from TTF | ||||||
|     fontPosition.y = screenHeight/2 - fontBm.baseSize/2 - 80; |     // NOTE: We define a font base size of 32 pixels tall and up-to 250 characters | ||||||
|  |     Font fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250); | ||||||
|  |      | ||||||
|  |     bool useTtf = false; | ||||||
|  |  | ||||||
|     SetTargetFPS(60); |     SetTargetFPS(60); | ||||||
|     //-------------------------------------------------------------------------------------- |     //-------------------------------------------------------------------------------------- | ||||||
| @@ -40,7 +43,8 @@ int main() | |||||||
|     { |     { | ||||||
|         // Update |         // Update | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|         // TODO: Update variables here... |         if (IsKeyDown(KEY_SPACE)) useTtf = true; | ||||||
|  |         else useTtf = false; | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|         // Draw |         // Draw | ||||||
| @@ -49,8 +53,18 @@ int main() | |||||||
|  |  | ||||||
|             ClearBackground(RAYWHITE); |             ClearBackground(RAYWHITE); | ||||||
|              |              | ||||||
|             DrawTextEx(fontBm, msgBm, fontPosition, fontBm.baseSize, 0, MAROON); |             DrawText("Press SPACE to use TTF generated font", 20, 20, 20, LIGHTGRAY); | ||||||
|             DrawTextEx(fontTtf, msgTtf, (Vector2){ 75.0f, 240.0f }, fontTtf.baseSize*0.8f, 2, LIME); |  | ||||||
|  |             if (!useTtf) | ||||||
|  |             { | ||||||
|  |                 DrawTextEx(fontBm, msg, (Vector2){ 20.0f, 100.0f }, fontBm.baseSize, 2, MAROON); | ||||||
|  |                 DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 DrawTextEx(fontTtf, msg, (Vector2){ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME); | ||||||
|  |                 DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY); | ||||||
|  |             } | ||||||
|  |  | ||||||
|         EndDrawing(); |         EndDrawing(); | ||||||
|         //---------------------------------------------------------------------------------- |         //---------------------------------------------------------------------------------- | ||||||
|   | |||||||
| Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 20 KiB | 
| @@ -1,65 +0,0 @@ | |||||||
| /******************************************************************************************* |  | ||||||
| * |  | ||||||
| *   raylib [text] example - BMFont unordered chars loading and drawing |  | ||||||
| * |  | ||||||
| *   This example has been created using raylib 1.4 (www.raylib.com) |  | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) |  | ||||||
| * |  | ||||||
| *   Copyright (c) 2016 Ramon Santamaria (@raysan5) |  | ||||||
| * |  | ||||||
| ********************************************************************************************/ |  | ||||||
|  |  | ||||||
| #include "raylib.h" |  | ||||||
|  |  | ||||||
| int main() |  | ||||||
| { |  | ||||||
|     // Initialization |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|     int screenWidth = 800; |  | ||||||
|     int screenHeight = 450; |  | ||||||
|  |  | ||||||
|     InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont unordered loading and drawing"); |  | ||||||
|  |  | ||||||
|     // NOTE: Using chars outside the [32..127] limits! |  | ||||||
|     // NOTE: If a character is not found in the font, it just renders a space |  | ||||||
|     const char msg[256] = "ASCII extended characters:\n¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆ\nÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæ\nçèéêëìíîïðñòóôõö÷øùúûüýþÿ"; |  | ||||||
|  |  | ||||||
|     // NOTE: Loaded font has an unordered list of characters (chars in the range 32..255) |  | ||||||
|     Font font = LoadFont("resources/pixantiqua.fnt");       // BMFont (AngelCode) |  | ||||||
|  |  | ||||||
|     SetTargetFPS(60); |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|     // Main game loop |  | ||||||
|     while (!WindowShouldClose())    // Detect window close button or ESC key |  | ||||||
|     { |  | ||||||
|         // Update |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|         // TODO: Update variables here... |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|         // Draw |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|         BeginDrawing(); |  | ||||||
|  |  | ||||||
|             ClearBackground(RAYWHITE); |  | ||||||
|  |  | ||||||
|             DrawText("Font name:       PixAntiqua", 40, 50, 20, GRAY); |  | ||||||
|             DrawText(FormatText("Font base size:           %i", font.baseSize), 40, 80, 20, GRAY); |  | ||||||
|             DrawText(FormatText("Font chars number:     %i", font.charsCount), 40, 110, 20, GRAY); |  | ||||||
|              |  | ||||||
|             DrawTextEx(font, msg, (Vector2){ 40, 180 }, font.baseSize, 0, MAROON); |  | ||||||
|  |  | ||||||
|         EndDrawing(); |  | ||||||
|         //---------------------------------------------------------------------------------- |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // De-Initialization |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|     UnloadFont(font);     // AngelCode Font unloading |  | ||||||
|      |  | ||||||
|     CloseWindow();                // Close window and OpenGL context |  | ||||||
|     //-------------------------------------------------------------------------------------- |  | ||||||
|  |  | ||||||
|     return 0; |  | ||||||
| } |  | ||||||
| Before Width: | Height: | Size: 18 KiB | 
| @@ -5,7 +5,9 @@ | |||||||
| *   This example has been created using raylib 2.3 (www.raylib.com) | *   This example has been created using raylib 2.3 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2018 Vlad Adrian (@demizdor) | *   Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
| 
 | 
 | ||||||
| @@ -37,9 +39,7 @@ int main() | |||||||
|     const int maxHeight = screenHeight - 160; |     const int maxHeight = screenHeight - 160; | ||||||
|      |      | ||||||
|     Vector2 lastMouse = { 0, 0 };   // Stores last mouse coordinates
 |     Vector2 lastMouse = { 0, 0 };   // Stores last mouse coordinates
 | ||||||
| 
 |  | ||||||
|     Color borderColor = MAROON;     // Container border color
 |     Color borderColor = MAROON;     // Container border color
 | ||||||
| 
 |  | ||||||
|     Font font = GetFontDefault();   // Get default system font
 |     Font font = GetFontDefault();   // Get default system font
 | ||||||
|      |      | ||||||
|     SetTargetFPS(60); |     SetTargetFPS(60); | ||||||
| Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB | 
| @@ -5,6 +5,8 @@ | |||||||
| *   This example has been created using raylib 2.5 (www.raylib.com) | *   This example has been created using raylib 2.5 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
|  | *   Example contributed by Vlad Adrian (@demizdor) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
| *   Copyright (c) 2019 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | *   Copyright (c) 2019 Vlad Adrian (@demizdor) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
|   | |||||||
| Before Width: | Height: | Size: 18 KiB | 
| @@ -7,7 +7,9 @@ | |||||||
| *   This example has been created using raylib 2.0 (www.raylib.com) | *   This example has been created using raylib 2.0 (www.raylib.com) | ||||||
| *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) | ||||||
| * | * | ||||||
| *   Copyright (c) 2016 Ramon Santamaria (@raysan5) | *   Example contributed by Jorge A. Gomes (@overdev) and reviewed by Ramon Santamaria (@raysan5) | ||||||
|  | * | ||||||
|  | *   Copyright (c) 2018 Jorge A. Gomes (@overdev) and Ramon Santamaria (@raysan5) | ||||||
| * | * | ||||||
| ********************************************************************************************/ | ********************************************************************************************/ | ||||||
| 
 | 
 | ||||||
| @@ -24,22 +26,25 @@ int main() | |||||||
| 
 | 
 | ||||||
|     // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
 |     // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
 | ||||||
|     Texture2D nPatchTexture = LoadTexture("resources/ninepatch_button.png"); |     Texture2D nPatchTexture = LoadTexture("resources/ninepatch_button.png"); | ||||||
|     Vector2 mousePosition; |  | ||||||
|     Vector2 origin = {0.0f, 0.0f}; |  | ||||||
|      |      | ||||||
|     // The location and size of the n-patches.
 |     Vector2 mousePosition = { 0 }; | ||||||
|     Rectangle dstRec1 = {480.0f, 160.0f, 32.0f, 32.0f}; |     Vector2 origin = { 0.0f, 0.0f }; | ||||||
|     Rectangle dstRec2 = {160.0f, 160.0f, 32.0f, 32.0f}; | 
 | ||||||
|     Rectangle dstRecH = {160.0f, 93.0f, 32.0f, 32.0f};   // this rec's height is ignored
 |     // Position and size of the n-patches
 | ||||||
|     Rectangle dstRecV = {92.0f, 160.0f, 32.0f, 32.0f};   // this rec's width is ignored
 |     Rectangle dstRec1 = { 480.0f, 160.0f, 32.0f, 32.0f }; | ||||||
|  |     Rectangle dstRec2 = { 160.0f, 160.0f, 32.0f, 32.0f }; | ||||||
|  |     Rectangle dstRecH = { 160.0f, 93.0f, 32.0f, 32.0f }; | ||||||
|  |     Rectangle dstRecV = { 92.0f, 160.0f, 32.0f, 32.0f }; | ||||||
| 
 | 
 | ||||||
|     // A 9-patch (NPT_9PATCH) changes its sizes in both axis
 |     // A 9-patch (NPT_9PATCH) changes its sizes in both axis
 | ||||||
|     NPatchInfo ninePatchInfo1 = {(Rectangle){0.0f, 0.0f, 64.0f, 64.0f}, 12, 40, 12, 12, NPT_9PATCH }; |     NPatchInfo ninePatchInfo1 = { (Rectangle){ 0.0f, 0.0f, 64.0f, 64.0f }, 12, 40, 12, 12, NPT_9PATCH }; | ||||||
|     NPatchInfo ninePatchInfo2 = {(Rectangle){0.0f, 128.0f, 64.0f, 64.0f}, 16, 16, 16, 16, NPT_9PATCH }; |     NPatchInfo ninePatchInfo2 = { (Rectangle){ 0.0f, 128.0f, 64.0f, 64.0f }, 16, 16, 16, 16, NPT_9PATCH }; | ||||||
|  |      | ||||||
|     // A horizontal 3-patch (NPT_3PATCH_HORIZONTAL) changes its sizes along the x axis only
 |     // A horizontal 3-patch (NPT_3PATCH_HORIZONTAL) changes its sizes along the x axis only
 | ||||||
|     NPatchInfo h3PatchInfo = {(Rectangle){0.0f,  64.0f, 64.0f, 64.0f}, 8, 8, 8, 8, NPT_3PATCH_HORIZONTAL }; |     NPatchInfo h3PatchInfo = { (Rectangle){ 0.0f,  64.0f, 64.0f, 64.0f }, 8, 8, 8, 8, NPT_3PATCH_HORIZONTAL }; | ||||||
|  |      | ||||||
|     // A vertical 3-patch (NPT_3PATCH_VERTICAL) changes its sizes along the y axis only
 |     // A vertical 3-patch (NPT_3PATCH_VERTICAL) changes its sizes along the y axis only
 | ||||||
|     NPatchInfo v3PatchInfo = {(Rectangle){0.0f, 192.0f, 64.0f, 64.0f}, 6, 6, 6, 6, NPT_3PATCH_VERTICAL }; |     NPatchInfo v3PatchInfo = { (Rectangle){ 0.0f, 192.0f, 64.0f, 64.0f }, 6, 6, 6, 6, NPT_3PATCH_VERTICAL }; | ||||||
|      |      | ||||||
|     SetTargetFPS(60); |     SetTargetFPS(60); | ||||||
|     //---------------------------------------------------------------------------------------
 |     //---------------------------------------------------------------------------------------
 | ||||||
| @@ -50,7 +55,8 @@ int main() | |||||||
|         // Update
 |         // Update
 | ||||||
|         //----------------------------------------------------------------------------------
 |         //----------------------------------------------------------------------------------
 | ||||||
|         mousePosition = GetMousePosition(); |         mousePosition = GetMousePosition(); | ||||||
|         // resize the n-patches based on mouse position.
 |          | ||||||
|  |         // Resize the n-patches based on mouse position
 | ||||||
|         dstRec1.width = mousePosition.x - dstRec1.x; |         dstRec1.width = mousePosition.x - dstRec1.x; | ||||||
|         dstRec1.height = mousePosition.y - dstRec1.y; |         dstRec1.height = mousePosition.y - dstRec1.y; | ||||||
|         dstRec2.width = mousePosition.x - dstRec2.x; |         dstRec2.width = mousePosition.x - dstRec2.x; | ||||||
| @@ -58,7 +64,7 @@ int main() | |||||||
|         dstRecH.width = mousePosition.x - dstRecH.x; |         dstRecH.width = mousePosition.x - dstRecH.x; | ||||||
|         dstRecV.height = mousePosition.y - dstRecV.y; |         dstRecV.height = mousePosition.y - dstRecV.y; | ||||||
| 
 | 
 | ||||||
|         // set a minimum width and/or height
 |         // Set a minimum width and/or height
 | ||||||
|         if (dstRec1.width < 1.0f) dstRec1.width = 1.0f; |         if (dstRec1.width < 1.0f) dstRec1.width = 1.0f; | ||||||
|         if (dstRec1.width > 300.0f) dstRec1.width = 300.0f; |         if (dstRec1.width > 300.0f) dstRec1.width = 300.0f; | ||||||
|         if (dstRec1.height < 1.0f) dstRec1.height = 1.0f; |         if (dstRec1.height < 1.0f) dstRec1.height = 1.0f; | ||||||
| @@ -82,16 +88,11 @@ int main() | |||||||
|             DrawTextureNPatch(nPatchTexture, v3PatchInfo, dstRecV, origin, 0.0f, WHITE); |             DrawTextureNPatch(nPatchTexture, v3PatchInfo, dstRecV, origin, 0.0f, WHITE); | ||||||
|              |              | ||||||
|             // Draw the source texture
 |             // Draw the source texture
 | ||||||
|             DrawRectangleLines( 5, 88, 74, 266, BLUE); |             DrawRectangleLines(5, 88, 74, 266, BLUE); | ||||||
|             DrawTexture(nPatchTexture, 10, 93, WHITE); |             DrawTexture(nPatchTexture, 10, 93, WHITE); | ||||||
|             DrawText("TEXTURE", 15, 360, 10, DARKGRAY); |             DrawText("TEXTURE", 15, 360, 10, DARKGRAY); | ||||||
| 
 | 
 | ||||||
|             DrawRectangle( 10, 10, 250, 73, Fade(SKYBLUE, 0.5)); |             DrawText("Move the mouse to stretch or shrink the n-patches", 10, 20, 20, DARKGRAY); | ||||||
|             DrawRectangleLines( 10, 10, 250, 73, BLUE); |  | ||||||
| 
 |  | ||||||
|             DrawText("9-Patch and 3-Patch example", 20, 20, 10, BLACK); |  | ||||||
|             DrawText("  Move the mouse to stretch or", 40, 40, 10, DARKGRAY); |  | ||||||
|             DrawText("  shrink the n-patches.", 40, 60, 10, DARKGRAY); |  | ||||||
| 
 | 
 | ||||||
|         EndDrawing(); |         EndDrawing(); | ||||||
|         //----------------------------------------------------------------------------------
 |         //----------------------------------------------------------------------------------
 | ||||||
							
								
								
									
										
											BIN
										
									
								
								examples/textures/textures_npatch_drawing.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 26 KiB | 
 Ray
					Ray