diff options
author | quou <quou@disroot.org> | 2024-07-27 18:02:17 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-07-27 18:02:17 +1000 |
commit | 7d6d4d11b5e4da38b82cbad705539e64c83788cc (patch) | |
tree | 1eb28ee17beb9e4be25984a7f70713d7b7ac86af | |
parent | 636f4f366b9a0f1f365f9b5132273f90fab0d353 (diff) |
ren_rect
-rw-r--r-- | render.c | 19 | ||||
-rw-r--r-- | render.h | 3 |
2 files changed, 21 insertions, 1 deletions
@@ -211,6 +211,25 @@ void ren_point(Renderer* r, Colour c, int x, int y) { r->t[x + y * r->vp[0]] = c; } +void ren_rect(Renderer* r, Colour c, const Rect* re) { + Rect rect = *re; + Colour* d; + int s, y, ey, ex; + rect_clipr(&rect, r->clip); + d = &r->t[rect.x + rect.y * r->vp[0]]; + s = r->vp[0] - rect.w; + ex = rect.x + rect.w; + ey = rect.y + rect.h; + for (y = rect.y; y < ey; y++) { + int x; + for (x = rect.x; x < ex; x++) { + *d = blend(*d, c); + d++; + } + d += s; + } +} + #define imp_ren_char(chw, chh, fw, data) \ int i, j, k, l, ex, ey, s; \ Colour* dst; \ @@ -40,7 +40,7 @@ typedef struct Mesh { Mesh_Vert* verts; } Mesh; -typedef struct { +typedef struct Renderer { Colour* t; int* d; int asp, n; @@ -69,6 +69,7 @@ void ren_clearc(Renderer* r, Colour c); void ren_cleard(Renderer* r, int depth); void ren_clip(Renderer* r, const Rect* c); void ren_point(Renderer* r, Colour c, int x, int y); +void ren_rect(Renderer* r, Colour c, const Rect*); void ren_char( Renderer* r, Colour c, |