-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
36 lines (26 loc) · 1.44 KB
/
example.c
File metadata and controls
36 lines (26 loc) · 1.44 KB
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
#include "Roadrunner.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
int main() {
rrSurface mainSurface;
rrSurface sth;
rrFont font;
rrBitmap(&mainSurface, 256, 256);
rrClear(0xff0000ff, &mainSurface);
rrDrawCircleLines((rrPoint){(mainSurface.width / 2), (mainSurface.height / 2)}, (mainSurface.height / 2), 0xffffffff, &mainSurface);
rrDrawCircle((rrPoint){(mainSurface.width / 2), (mainSurface.height / 2)}, 20 - 1, 0x7f7f7fff, &mainSurface);
rrBitmapImage(&sth, "tojisnip.png");
rrLoadFont(&font, "tigrfont.png", 1252);
rrSetBlendMode(&mainSurface, RR_MODE_BLEND);
rrDrawTriangle((rrTri){(rrPoint){40, 20}, (rrPoint){40, 30}, (rrPoint){80, 30}}, 0x00ff00ff, &mainSurface);
rrDrawRectangleLines((rrRect){20, 20, 10, 10}, 0xffffffff, &mainSurface);
rrDrawRectangle((rrRect){30, 30, 10, 10}, 0xffff00f0, &mainSurface);
rrBlitScaled(&sth, &mainSurface, (rrRect){0, 0, 16, 32}, (rrRect){(mainSurface.height / 2) - (32 / 2), (mainSurface.height / 2) - (64 / 2), 32, 64}, (rrPoint){16 / 2, 32 / 2}, 0);
rrDrawText(&font, (rrPoint){0, mainSurface.height - rrTextHeight(&font, "Roadrunner!")}, "Roadrunner!", &mainSurface);
rrSetBlendMode(&mainSurface, RR_MODE_NONE);
rrChangeEndianness(&mainSurface);
stbi_write_png("out.png", mainSurface.width, mainSurface.height, mainSurface.bytesPerPixel, mainSurface.pixels, mainSurface.width * mainSurface.bytesPerPixel);
rrFreeSurface(&mainSurface);
rrFreeSurface(&sth);
return 0;
}