ref: 8bc07106249a28dec80e91228b945814efc60d70
parent: bfe30304a0a86efbb8dd42a0d16ab31819fd00c4
author: Sigrid Haflínudóttir <[email protected]>
date: Thu Jan 2 12:49:28 EST 2020
fix alpha handling, use draw.h funcs to construct rects/points
--- a/demo/renderer_plan9.c
+++ b/demo/renderer_plan9.c
@@ -25,7 +25,7 @@
diff = 0;
leasti = 0;
- c = color.r<<24 | color.g<<16 | color.b<<8 | color.a;
+ c = setalpha(color.r<<24 | color.g<<16 | color.b<<8, color.a);
if (c == DBlack)
return display->black;
if (c == DWhite)
@@ -43,13 +43,13 @@
if (i >= nelem(colors)) {
freeimage(colors[leasti]);
rgba[leasti] = c;
- colors[leasti] = allocimage(display, (Rectangle){ZP, (Point){1, 1}}, RGBA32, 1, c);
+ colors[leasti] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, c);
lastused[leasti] = frame;
return colors[leasti];
}
rgba[numcolors] = c;
- colors[numcolors] = allocimage(display, (Rectangle){ZP, (Point){1, 1}}, RGBA32, 1, c);
+ colors[numcolors] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, c);
return colors[numcolors++];
}
@@ -93,12 +93,7 @@
void
r_draw_text(mu_Font font, const char *text, mu_Vec2 pos, mu_Color color) {
- Point p;
-
- p = screen->r.min;
- p.x += pos.x;
- p.y += pos.y;
- string(screen, p, getcolor(color), ZP, font, text);
+ string(screen, addpt(screen->r.min, Pt(pos.x, pos.y)), getcolor(color), ZP, font, text);
}
void
@@ -111,7 +106,7 @@
rect.w = atlas[id].w;
rect.h = atlas[id].h;
r = screenrect(rect);
- draw(screen, r, atlasimage, nil, (Point){atlas[id].x, atlas[id].y});
+ draw(screen, r, atlasimage, nil, Pt(atlas[id].x, atlas[id].y));
}
int