summaryrefslogtreecommitdiff
path: root/src/resources/resources.c
blob: c1b78b54e00416829a4d6077263238ea535bf37f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "resources.h"
#include <stddef.h>
#include <raylib.h>

Font MainFont;
Font MonoFont;

Texture ButtonsAtlas;

Texture PrepareTexture(char *location) {
    Image img = LoadImage(location);
    // Applying colorscheme
    ImageColorReplace(&img, 
            (Color) { .r = 0xFF, .g = 0x00, .b = 0x00, .a = 0xFF }, 
            COLORSCHEME_RED);
    ImageColorReplace(&img, 
            (Color) { .r = 0x00, .g = 0xFF, .b = 0x00, .a = 0xFF }, 
            COLORSCHEME_GREEN);
    ImageColorReplace(&img, 
            (Color) { .r = 0XFF, .g = 0x7F, .b = 0x00, .a = 0xFF }, 
            COLORSCHEME_YELLOW);
    ImageColorReplace(&img, 
            (Color) { .r = 0x00, .g = 0x00, .b = 0xFF, .a = 0xFF }, 
            COLORSCHEME_ORANGE);
    ImageColorReplace(&img, 
            (Color) { .r = 0x00, .g = 0x00, .b = 0x00, .a = 0xFF }, 
            COLORSCHEME_BROWN);
    ImageColorReplace(&img, 
            (Color) { .r = 0xFF, .g = 0xFF, .b = 0xFF, .a = 0xFF }, 
            COLORSCHEME_WHITE);
    Texture outp = LoadTextureFromImage(img);
    UnloadImage(img);
    return outp;
}

void LoadResources() {
    MainFont = LoadFontEx("assets/fonts/coolvetica.ttf", 100, NULL, 0);
    MonoFont = LoadFontEx("assets/fonts/monofont.ttf", 100, NULL, 0);

    ButtonsAtlas = PrepareTexture("assets/textures/buttons_atlas.png");
}

Texture *GetButtonsAtlas() {
    return &ButtonsAtlas;
}

Font *GetMainFont() { return &MainFont; }
Font *GetMonoFont() { return &MonoFont; }

void DrawStripe(int start_step, int end_step, Color color) {
    int height = GetScreenHeight();
    Vector2 p1 = { .x = start_step, .y = 0 },
            p2 = { .x = end_step, .y = height },
            p3 = { .x = start_step, .y = height };
   DrawTriangle(p1, p2, p3, color);
   p2 = p3;
   p3 = p1;
   p3.x += (start_step - end_step);
   DrawTriangle(p1, p2, p3, color);
}

void DrawBackground() {
    ClearBackground(COLORSCHEME_WHITE);
    double step = GetScreenWidth() / 6.0f;
    DrawStripe(step * 2, step, COLORSCHEME_YELLOW);
    DrawStripe(step * 3 - 1, step * 2 - 1, COLORSCHEME_ORANGE);
    DrawStripe(step * 4 - 2, step * 3 - 2, COLORSCHEME_RED);
    DrawStripe(step * 5 - 3, step * 4 - 3, COLORSCHEME_BROWN);
    DrawRectangle(step * 5 - 3, 0,
            step * 2, GetScreenHeight(),
            COLORSCHEME_BROWN);
}