Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,285 questions

52,311 answers

573 users

How to draw a rectangle with Raylib in C

1 Answer

0 votes
#include "raylib.h"

#define WIDTH 800
#define HEIGHT 600

int main()
{
    InitWindow(WIDTH, HEIGHT, "Raylib Draw Rectangle");

    // Main game loop
    while (!WindowShouldClose()) // Detect window close button or ESC key
    {
        BeginDrawing();

        ClearBackground(RAYWHITE);

        // Draw a color-filled rectangle
        // void DrawRectangle(int posX, int posY, int width, int height, Color color);  
        DrawRectangle(WIDTH / 4 * 2 - 60, 100, 130, 60, GREEN);

        // Draw a vertical-gradient-filled rectangle
        // void DrawRectangleGradientH(int posX, int posY, int width, int height, Color left, Color right);
        DrawRectangleGradientH(WIDTH / 4 * 2 - 90, 170, 200, 130, GREEN, BLUE);

        // Draw rectangle outline
        // void DrawRectangleLines(int posX, int posY, int width, int height, Color color);     
        DrawRectangleLines(WIDTH / 4 * 2 - 60, 310, 140, 60, GREEN); 

        EndDrawing();
    }

    CloseWindow(); // Close window and OpenGL context

    return 0;
}


/*
run:


*/

 



answered Jan 12, 2025 by avibootz

Related questions

1 answer 95 views
95 views asked Jan 16, 2025 by avibootz
1 answer 133 views
133 views asked Jan 12, 2025 by avibootz
1 answer 111 views
111 views asked Jan 12, 2025 by avibootz
1 answer 102 views
...