fix: sync template sysroot, add script

This commit is contained in:
2026-06-12 11:56:20 +02:00
parent 22691c5c17
commit 44f86a8b19
33 changed files with 5172 additions and 147 deletions
+29 -39
View File
@@ -71,6 +71,35 @@ struct Canvas {
}
}
void fill_rect_alpha(int x, int y, int rw, int rh, Color c) {
if (c.a == 0) return;
if (c.a == 255) { fill_rect(x, y, rw, rh, c); return; }
int x0 = gui_max(x, 0), y0 = gui_max(y, 0);
int x1 = gui_min(x + rw, w), y1 = gui_min(y + rh, h);
if (x0 >= x1 || y0 >= y1) return;
uint32_t a = c.a;
uint32_t inv_a = 255 - a;
uint32_t src_r = a * c.r;
uint32_t src_g = a * c.g;
uint32_t src_b = a * c.b;
for (int dy = y0; dy < y1; dy++) {
uint32_t* row = pixels + dy * w;
for (int dx = x0; dx < x1; dx++) {
uint32_t p = row[dx];
uint32_t dr = (p >> 16) & 0xFF;
uint32_t dg = (p >> 8) & 0xFF;
uint32_t db = p & 0xFF;
uint32_t nr = (src_r + dr * inv_a) / 255;
uint32_t ng = (src_g + dg * inv_a) / 255;
uint32_t nb = (src_b + db * inv_a) / 255;
row[dx] = (0xFFu << 24) | (nr << 16) | (ng << 8) | nb;
}
}
}
void fill_rounded_rect(int x, int y, int rw, int rh, int radius, Color c) {
if (radius <= 0) { fill_rect(x, y, rw, rh, c); return; }
uint32_t px = c.to_pixel();
@@ -135,51 +164,12 @@ struct Canvas {
void text(int x, int y, const char* str, Color c) {
if (fonts::system_font && fonts::system_font->valid) {
fonts::system_font->draw_to_buffer(pixels, w, h, x, y, str, c, fonts::UI_SIZE);
return;
}
uint32_t px = c.to_pixel();
for (int i = 0; str[i] && x + (i + 1) * FONT_WIDTH <= w; i++) {
const uint8_t* glyph = &font_data[(unsigned char)str[i] * FONT_HEIGHT];
int cx = x + i * FONT_WIDTH;
for (int fy = 0; fy < FONT_HEIGHT && y + fy < h; fy++) {
uint8_t bits = glyph[fy];
for (int fx = 0; fx < FONT_WIDTH; fx++) {
if (bits & (0x80 >> fx)) {
int dx = cx + fx;
int dy = y + fy;
if (dx >= 0 && dx < w && dy >= 0)
pixels[dy * w + dx] = px;
}
}
}
}
}
void text_2x(int x, int y, const char* str, Color c) {
if (fonts::system_font && fonts::system_font->valid) {
fonts::system_font->draw_to_buffer(pixels, w, h, x, y, str, c, fonts::LARGE_SIZE);
return;
}
uint32_t px = c.to_pixel();
for (int i = 0; str[i] && x + (i + 1) * FONT_WIDTH * 2 <= w; i++) {
const uint8_t* glyph = &font_data[(unsigned char)str[i] * FONT_HEIGHT];
int cx = x + i * FONT_WIDTH * 2;
for (int fy = 0; fy < FONT_HEIGHT; fy++) {
uint8_t bits = glyph[fy];
for (int fx = 0; fx < FONT_WIDTH; fx++) {
if (bits & (0x80 >> fx)) {
int dx = cx + fx * 2;
int dy = y + fy * 2;
for (int sy = 0; sy < 2; sy++)
for (int sx = 0; sx < 2; sx++) {
int pdx = dx + sx;
int pdy = dy + sy;
if (pdx >= 0 && pdx < w && pdy >= 0 && pdy < h)
pixels[pdy * w + pdx] = px;
}
}
}
}
}
}