Commit a2e50973c3de3f1066d25f308585a3f71719c383
1 parent
7804d394
Added filled triangle to primlib
Showing
2 changed files
with
10 additions
and
0 deletions
primlib.c
@@ -39,6 +39,15 @@ void gfx_line(int x1, int y1, int x2, int y2, enum color c) { | @@ -39,6 +39,15 @@ void gfx_line(int x1, int y1, int x2, int y2, enum color c) { | ||
39 | 255); | 39 | 255); |
40 | } | 40 | } |
41 | 41 | ||
42 | +void gfx_filledTriangle(int x1, int y1, int x2, int y2, int x3, int y3, enum color c) { | ||
43 | + assert(c < COLOR_MAX); | ||
44 | + Sint16 xtab[] = {x1, x2, x3}; | ||
45 | + Sint16 ytab[] = {y1, y2, y3}; | ||
46 | + filledPolygonRGBA(renderer, xtab, ytab, 3, colors[c].r, colors[c].g, colors[c].b, | ||
47 | + 255); | ||
48 | +} | ||
49 | + | ||
50 | + | ||
42 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c) { | 51 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c) { |
43 | assert(c < COLOR_MAX); | 52 | assert(c < COLOR_MAX); |
44 | rectangleRGBA(renderer, x1, y1, x2, y2, colors[c].r, colors[c].g, colors[c].b, | 53 | rectangleRGBA(renderer, x1, y1, x2, y2, colors[c].r, colors[c].g, colors[c].b, |
primlib.h
@@ -8,6 +8,7 @@ enum color { BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE, COLOR_MAX }; | @@ -8,6 +8,7 @@ enum color { BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE, COLOR_MAX }; | ||
8 | void gfx_pixel(int x, int y, enum color c); | 8 | void gfx_pixel(int x, int y, enum color c); |
9 | void gfx_line(int x1, int y1, int x2, int y2, enum color c); | 9 | void gfx_line(int x1, int y1, int x2, int y2, enum color c); |
10 | void gfx_circle(int x, int y, int r, enum color c); | 10 | void gfx_circle(int x, int y, int r, enum color c); |
11 | +void gfx_filledTriangle(int x1, int y1, int x2, int y2, int x3, int y3, enum color c); | ||
11 | void gfx_filledRect(int x1, int y1, int x2, int y2, enum color c); | 12 | void gfx_filledRect(int x1, int y1, int x2, int y2, enum color c); |
12 | void gfx_filledCircle(int x, int y, int r, enum color c); | 13 | void gfx_filledCircle(int x, int y, int r, enum color c); |
13 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c); | 14 | void gfx_rect(int x1, int y1, int x2, int y2, enum color c); |