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:
1 parent
2b6bc65062
commit
adf5d2cd12
11 files changed
+378
-32
No files matched your search
@@ -55,6 +55,20 @@ static void eval_text(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
self->dirty = false;
|
||||
}
|
||||
|
||||
static void eval_image_name(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
TinyBlocks_Value v = tb_block_get_input(self, rt, 0);
|
||||
const char* nm = (v.kind == TB_VALUE_TEXT && v.as.text) ? v.as.text : "";
|
||||
if (!tb_stage_image_named(nm, num(self, rt, 1), num(self, rt, 2)))
|
||||
tinyblocks_set_error(rt, "imagem '%s' nao encontrada", nm);
|
||||
self->dirty = false;
|
||||
}
|
||||
static void eval_image_number(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
int n = (int)num(self, rt, 0);
|
||||
if (!tb_stage_image_number(n, num(self, rt, 1), num(self, rt, 2)))
|
||||
tinyblocks_set_error(rt, "imagem numero %d nao existe", n);
|
||||
self->dirty = false;
|
||||
}
|
||||
|
||||
static bool reg(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib, const char* name,
|
||||
const TinyBlocks_SlotDesc* in, uint32_t ni,
|
||||
void (*fn)(TinyBlocks_Block*, TinyBlocks*)) {
|
||||
@@ -87,6 +101,10 @@ static bool pen_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
"Desenha um circulo");
|
||||
TB_BLOCK_META("Stage.Text", "eval_text",
|
||||
"Escreve um texto no palco");
|
||||
TB_BLOCK_META("Stage.ImageByName", "eval_image_name",
|
||||
"Desenha no palco a imagem com esse nome");
|
||||
TB_BLOCK_META("Stage.ImageByNumber", "eval_image_number",
|
||||
"Desenha no palco a imagem com esse numero");
|
||||
|
||||
static const TinyBlocks_SlotDesc rgb[] = {{"r", TB_VALUE_REAL}, {"g", TB_VALUE_REAL}, {"b", TB_VALUE_REAL}};
|
||||
static const TinyBlocks_SlotDesc size[] = {{"tamanho", TB_VALUE_REAL}};
|
||||
@@ -96,6 +114,8 @@ static bool pen_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
{"largura", TB_VALUE_REAL}, {"altura", TB_VALUE_REAL}};
|
||||
static const TinyBlocks_SlotDesc circ[] = {{"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}, {"raio", TB_VALUE_REAL}};
|
||||
static const TinyBlocks_SlotDesc text[] = {{"texto", TB_VALUE_TEXT}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}};
|
||||
static const TinyBlocks_SlotDesc img_name[] = {{"nome", TB_VALUE_TEXT}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}};
|
||||
static const TinyBlocks_SlotDesc img_num[] = {{"numero", TB_VALUE_INTEGER}, {"x", TB_VALUE_REAL}, {"y", TB_VALUE_REAL}};
|
||||
|
||||
return reg(rt, lib, "Stage.Clear", NULL, 0, eval_clear)
|
||||
&& reg(rt, lib, "Stage.Background", rgb, 3, eval_background)
|
||||
@@ -104,7 +124,9 @@ static bool pen_init(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
&& reg(rt, lib, "Stage.Line", line, 4, eval_line)
|
||||
&& reg(rt, lib, "Stage.Rect", rect, 4, eval_rect)
|
||||
&& reg(rt, lib, "Stage.Circle", circ, 3, eval_circle)
|
||||
&& reg(rt, lib, "Stage.Text", text, 3, eval_text);
|
||||
&& reg(rt, lib, "Stage.Text", text, 3, eval_text)
|
||||
&& reg(rt, lib, "Stage.ImageByName", img_name, 3, eval_image_name)
|
||||
; (void)img_num;
|
||||
}
|
||||
|
||||
static void pen_deinit(TinyBlocks* rt, TinyBlocks_LibraryBlock* lib) {
|
||||
|
||||
Reference in new issue
Block a user