diff options
| author | raysan5 <[email protected]> | 2019-07-28 15:33:55 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2019-07-28 15:33:55 +0200 |
| commit | b83d165764cd81de8bd5a0bb8260117787f419a4 (patch) | |
| tree | e8ac195716879ea0471d5e1f26a7755fc0d8a2f6 /examples/textures | |
| parent | 895f9613d21ecab734ddddec7159dc5e80d92d31 (diff) | |
| download | raylib-b83d165764cd81de8bd5a0bb8260117787f419a4.tar.gz raylib-b83d165764cd81de8bd5a0bb8260117787f419a4.zip | |
Replace tabs by spaces
Diffstat (limited to 'examples/textures')
| -rw-r--r-- | examples/textures/textures_mouse_painting.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/examples/textures/textures_mouse_painting.c b/examples/textures/textures_mouse_painting.c index 55c698c9..1c51d9d9 100644 --- a/examples/textures/textures_mouse_painting.c +++ b/examples/textures/textures_mouse_painting.c @@ -65,13 +65,13 @@ int main(void) // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //---------------------------------------------------------------------------------- - Vector2 mousePos = GetMousePosition(); + // Update + //---------------------------------------------------------------------------------- + Vector2 mousePos = GetMousePosition(); - // Switch between colors - if (IsKeyPressed(KEY_RIGHT)) colorSelected++; - else if (IsKeyPressed(KEY_LEFT)) colorSelected--; + // Switch between colors + if (IsKeyPressed(KEY_RIGHT)) colorSelected++; + else if (IsKeyPressed(KEY_LEFT)) colorSelected--; else if (IsKeyPressed(KEY_UP)) colorSelected -= 3; else if (IsKeyPressed(KEY_DOWN)) colorSelected += 3; @@ -91,41 +91,41 @@ int main(void) colorSelectedPrev = colorSelected; } - if (colorSelected >= MAX_COLORS_COUNT) colorSelected = MAX_COLORS_COUNT - 1; - else if (colorSelected < 0) colorSelected = 0; + if (colorSelected >= MAX_COLORS_COUNT) colorSelected = MAX_COLORS_COUNT - 1; + else if (colorSelected < 0) colorSelected = 0; // Change brush size - brushSize += GetMouseWheelMove()*5; - if (brushSize < 2) brushSize = 2; - if (brushSize > 50) brushSize = 50; + brushSize += GetMouseWheelMove()*5; + if (brushSize < 2) brushSize = 2; + if (brushSize > 50) brushSize = 50; - if (IsKeyPressed(KEY_C)) + if (IsKeyPressed(KEY_C)) { // Clear render texture to clear color - BeginTextureMode(target); - ClearBackground(colors[0]); - EndTextureMode(); - } + BeginTextureMode(target); + ClearBackground(colors[0]); + EndTextureMode(); + } - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) { // Paint circle into render texture // NOTE: To avoid discontinuous circles, we could store // previous-next mouse points and just draw a line using brush size - BeginTextureMode(target); - if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[colorSelected]); - EndTextureMode(); - } + BeginTextureMode(target); + if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[colorSelected]); + EndTextureMode(); + } - if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) + if (IsMouseButtonDown(MOUSE_RIGHT_BUTTON)) { colorSelected = 0; // Erase circle from render texture - BeginTextureMode(target); - if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[0]); - EndTextureMode(); - } + BeginTextureMode(target); + if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[0]); + EndTextureMode(); + } else colorSelected = colorSelectedPrev; // Check mouse hover save button @@ -152,16 +152,16 @@ int main(void) saveMessageCounter = 0; } } - //---------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); ClearBackground(RAYWHITE); - // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) - DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE); + // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) + DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE); // Draw drawing circle for reference if (mousePos.y > 50) @@ -194,8 +194,8 @@ int main(void) DrawText("IMAGE SAVED: my_amazing_texture_painting.png", 150, 180, 20, RAYWHITE); } - EndDrawing(); - //---------------------------------------------------------------------------------- + EndDrawing(); + //---------------------------------------------------------------------------------- } // De-Initialization |
