summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-07-27 18:02:17 +1000
committerquou <quou@disroot.org>2024-07-27 18:02:17 +1000
commit7d6d4d11b5e4da38b82cbad705539e64c83788cc (patch)
tree1eb28ee17beb9e4be25984a7f70713d7b7ac86af
parent636f4f366b9a0f1f365f9b5132273f90fab0d353 (diff)
ren_rect
-rw-r--r--render.c19
-rw-r--r--render.h3
2 files changed, 21 insertions, 1 deletions
diff --git a/render.c b/render.c
index 8e74082..9eb3af0 100644
--- a/render.c
+++ b/render.c
@@ -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; \
diff --git a/render.h b/render.h
index 9ce3015..b420c20 100644
--- a/render.h
+++ b/render.h
@@ -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,