diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-10-05 08:28:22 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-10-05 08:28:22 +0200 |
commit | d4f820e37bbb6571af4587adb2a3b3519d76849a (patch) | |
tree | 09f34b65f91c8f678c659d758ca967d5415c8d85 /examples/graph.c | |
parent | cb518b00efc8fe29df713e652450e90448340c29 (diff) | |
download | reduced_system_layer-d4f820e37bbb6571af4587adb2a3b3519d76849a.zip |
Draw triangles and lines
Diffstat (limited to 'examples/graph.c')
-rwxr-xr-x | examples/graph.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/examples/graph.c b/examples/graph.c new file mode 100755 index 0000000..c7b2877 --- /dev/null +++ b/examples/graph.c @@ -0,0 +1,66 @@ +#if 0 /* +#/ ================================================================ +#/ +#/ graph.c +#/ +#/ ================================================================ +#/ +#/ Self-compilation shell script +#/ +SRC=${0##*./} +BIN=${SRC%.*} +gcc \ + -Wall -Wextra -Werror -pedantic \ + -Wno-old-style-declaration \ + -Wno-missing-braces \ + -Wno-unused-variable \ + -Wno-unused-but-set-variable \ + -Wno-unused-parameter \ + -Wno-overlength-strings \ + -O3 \ + -fsanitize=undefined,address,leak -mshstk \ + -lX11 -lm \ + -o $BIN $SRC && \ + ./$BIN $@ && rm $BIN +exit $? # */ +#endif + +#include "../graphics.c" + +i32 main(i32 argc, c8 **argv) { + (void) argc; + (void) argv; + + platform = (Platform) { + .title = "Graph", + .frame_width = 960, + .frame_height = 720, + }; + + u32 WHITE = u32_from_rgb(1.f, 1.f, 1.f); + u32 BLACK = u32_from_rgb(0.f, 0.f, 0.f); + u32 RED = u32_from_rgb(1.f, 0.f, 0.f); + u32 BLUE = u32_from_rgb(0.f, 0.f, 1.f); + + p_init(); + + while (!platform.done) { + p_wait_events(); + + i64 x = platform.frame_width / 2; + i64 y = platform.frame_height / 2; + + fill_rectangle(OP_SET, WHITE, 0, 0, platform.frame_width, platform.frame_height); + + fill_triangle(OP_SET, RED, 100, 100, 200, 100, 150, 200); + + fill_line(OP_SET, BLUE, 100, 300, 300, 500, 30); + + fill_ellipse(OP_SET, BLACK, x - 140, y - 100, 280, 200); + + p_render_frame(); + } + + p_cleanup(); + return 0; +} |