Imagens no palco por nome/número, paleta recarregável e slider de zoom

- Core: armazém de imagens nomeadas (tb_image_store_*) e tb_stage_image*
  para desenhar imagens no palco pelo nome ou pelo número.
- Caneta: blocos "desenhe imagem nome/número".
- tinyblocks-api: tb_api_load_named/tb_api_find_library e mtime em ns;
  o editor carrega as libraries de categoria como .so quando existem,
  para a paleta recarregar ao vivo.
- Aba de imagem: slider de zoom no rodapé no lugar dos botões -/+.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-21 11:03:01 -03:00
1 parent 2b6bc65062
commit adf5d2cd12
11 files changed
+378 -32

No files matched your search

+27 -1
View File
@@ -13,13 +13,14 @@
#include <string.h>
#include "tinyblocks/tb_stage.h"
#include "tinyblocks/tb_image.h"
#define STAGE_W 480.f
#define STAGE_H 360.f
#define STAGE_MAX_CMDS 4000
#define STAGE_TEXT_FS 14.f
typedef enum { SC_RECT, SC_CIRCLE, SC_LINE, SC_TEXT } StageCmdKind;
typedef enum { SC_RECT, SC_CIRCLE, SC_LINE, SC_TEXT, SC_IMAGE } StageCmdKind;
typedef struct {
StageCmdKind kind;
@@ -27,6 +28,7 @@ typedef struct {
float size; /* espessura da caneta */
float col[3];
char text[96];
const TinyBlocks_Image* img; /* SC_IMAGE (vem do armazem de imagens) */
} StageCmd;
typedef struct {
@@ -103,6 +105,21 @@ void tb_stage_text(const char* text, float x, float y) {
}
}
bool tb_stage_image(const TinyBlocks_Image* img, float x, float y) {
if (!img) return false;
StageCmd* c = push(SC_IMAGE);
if (!c) return false;
c->a = x; c->b = y;
c->img = img;
return true;
}
bool tb_stage_image_named(const char* name, float x, float y) {
return tb_stage_image(tb_image_store_get(name), x, y);
}
bool tb_stage_image_number(int number, float x, float y) {
return tb_stage_image(tb_image_store_at(number), x, y);
}
void tb_stage_set_view(float w, float h) {
if (w > 0 && h > 0) { s_stage.view_w = w; s_stage.view_h = h; }
}
@@ -145,6 +162,15 @@ bool tb_stage_render(TinyBlocks_RenderableBlock* rb) {
tb_draw_stroke_line(rb, SX(c->a), SY(c->b), SX(c->c), SY(c->d),
c->size*sc, r, g, b, 1.f);
break;
case SC_IMAGE: {
const TinyBlocks_Image* im = c->img;
int iw = tb_image_width(im), ih = tb_image_height(im);
if (iw > 0 && ih > 0) {
float dw = iw * sc, dh = ih * sc;
tb_draw_image(rb, SX(c->a) - dw * 0.5f, SY(c->b) - dh * 0.5f, dw, dh, im);
}
break;
}
case SC_TEXT: {
float fs = STAGE_TEXT_FS * sc;
tb_draw_text(rb, SX(c->a), SY(c->b) + fs*0.36f, c->text, fs, r, g, b, 1.f);