#The most Begineer Drawing app in Raylib.

1 messages · Page 1 of 1 (latest)

gleaming bramble
#

I made this with raylib Please anyone don't laugh 🙁

#include <iostream>
#include <raylib.h>
#include <vector>
using namespace std;

int main() {
    Vector2 Window = {800, 600};
    SetTargetFPS(120);
    InitWindow(Window.x, Window.y, "Drawing App In Raylib C++");
    vector <Vector2> points;
    while (!WindowShouldClose())
    {
        Vector2 Mouse = GetMousePosition();
        BeginDrawing();
        ClearBackground(RAYWHITE);
        if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
        {
            points.push_back(Mouse);
        }
        for (int i = 0; i < points.size(); i++)
        {
            DrawCircle(points[i].x, points[i].y, 5, BLACK);
        }
        EndDrawing();
    }
    CloseWindow();
    return 0;
}

#

I just started learning raylib like 5-6 days ago

trail shale
#

Great little starter project! 😄

#

Some advice:
For better performance, I recommend initializing a texture and updating it whenever it is modified. Modifying the texture is as simple as defining an array of pixels and getting the mouse position within that array. (And you update the texture with that array)

For smoother drawing, if you save the last mouse position, you can draw a line between the previous and current mouse positions to make it seamless.

#

Using a texture not only significantly improves performance, but also allows you to easily save it as a file (by converting it into an Image and using ExportImage())

#

I guess if you don’t wanna bother with UpdateTexture() (or UpdateTextureRec()) and pixel arrays, you could just use a RenderTexture, which is a lot simpler

limpid charm
gleaming bramble