Entradas convertidas no core: fim dos helpers de conversão repetidos
- tb_block_input_text / _number / _integer / _truthy: a entrada do bloco
já convertida, despachando pela classe do valor. O texto de um valor
que não é texto fica em cache na conexão (sem buffers nos blocos).
- Saída com nome terminado em '?' vira o traço TB_SLOT_BOOLEAN na criação
do tipo (a convenção mora num lugar só; o editor só lê traços).
- Removidas ~35 funções locais (in_text, in_real, in_int, num, as_num,
input_name, value_num, value_truthy, value_to_str, item_text) em 22
libraries e no editor. Inteiros que truncavam (coordenadas de pixel)
continuam truncando; um número ligado a um campo de texto agora vira
texto ("42") em vez de "".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a5e36b3eed
commit
5ffc1741c2
27 files changed
+217
-416
No files matched your search
@@ -198,13 +198,6 @@ bool tb_vg_polygon(TinyBlocks_VectorData* v, const double* xy, int n, bool close
|
||||
|
||||
/* -- Blocos -------------------------------------------------------------- */
|
||||
|
||||
static double in_real(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
|
||||
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
|
||||
if (v.kind == TB_VALUE_REAL) return v.as.real;
|
||||
if (v.kind == TB_VALUE_INTEGER) return (double)v.as.integer;
|
||||
return 0.0;
|
||||
}
|
||||
static int in_int(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) { return (int)in_real(self, rt, i); }
|
||||
static TinyBlocks_VectorData* in_vec(TinyBlocks_Block* self, TinyBlocks* rt, uint32_t i) {
|
||||
TinyBlocks_Value v = tb_block_get_input(self, rt, i);
|
||||
return v.kind == TB_VALUE_VECTOR ? v.as.vector : NULL;
|
||||
@@ -225,27 +218,27 @@ static void eval_new(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
}
|
||||
static void eval_line(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
TinyBlocks_VectorData* v = in_vec(self, rt, 0);
|
||||
if (v) tb_vg_line(v, in_real(self,rt,1), in_real(self,rt,2), in_real(self,rt,3), in_real(self,rt,4),
|
||||
f01(in_real(self,rt,5)), f01(in_real(self,rt,6)), f01(in_real(self,rt,7)), 1.f,
|
||||
in_real(self,rt,8));
|
||||
if (v) tb_vg_line(v, tb_block_input_number(self,rt,1, 0), tb_block_input_number(self,rt,2, 0), tb_block_input_number(self,rt,3, 0), tb_block_input_number(self,rt,4, 0),
|
||||
f01(tb_block_input_number(self,rt,5, 0)), f01(tb_block_input_number(self,rt,6, 0)), f01(tb_block_input_number(self,rt,7, 0)), 1.f,
|
||||
tb_block_input_number(self,rt,8, 0));
|
||||
out_vec(self, v);
|
||||
}
|
||||
static void eval_rect(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
TinyBlocks_VectorData* v = in_vec(self, rt, 0);
|
||||
if (v) tb_vg_rect(v, in_real(self,rt,1), in_real(self,rt,2), in_real(self,rt,3), in_real(self,rt,4),
|
||||
f01(in_real(self,rt,5)), f01(in_real(self,rt,6)), f01(in_real(self,rt,7)), 1.f);
|
||||
if (v) tb_vg_rect(v, tb_block_input_number(self,rt,1, 0), tb_block_input_number(self,rt,2, 0), tb_block_input_number(self,rt,3, 0), tb_block_input_number(self,rt,4, 0),
|
||||
f01(tb_block_input_number(self,rt,5, 0)), f01(tb_block_input_number(self,rt,6, 0)), f01(tb_block_input_number(self,rt,7, 0)), 1.f);
|
||||
out_vec(self, v);
|
||||
}
|
||||
static void eval_circle(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
TinyBlocks_VectorData* v = in_vec(self, rt, 0);
|
||||
if (v) tb_vg_circle(v, in_real(self,rt,1), in_real(self,rt,2), in_real(self,rt,3),
|
||||
f01(in_real(self,rt,4)), f01(in_real(self,rt,5)), f01(in_real(self,rt,6)), 1.f);
|
||||
if (v) tb_vg_circle(v, tb_block_input_number(self,rt,1, 0), tb_block_input_number(self,rt,2, 0), tb_block_input_number(self,rt,3, 0),
|
||||
f01(tb_block_input_number(self,rt,4, 0)), f01(tb_block_input_number(self,rt,5, 0)), f01(tb_block_input_number(self,rt,6, 0)), 1.f);
|
||||
out_vec(self, v);
|
||||
}
|
||||
/* VG.Render (vetor, largura, altura, escala) -> imagem */
|
||||
static void eval_render(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
TinyBlocks_VectorData* v = in_vec(self, rt, 0);
|
||||
TinyBlocks_Image* im = tb_vg_render(v, in_int(self,rt,1), in_int(self,rt,2), (float)in_real(self,rt,3));
|
||||
TinyBlocks_Image* im = tb_vg_render(v, (int)tb_block_input_number(self,rt,1, 0), (int)tb_block_input_number(self,rt,2, 0), (float)tb_block_input_number(self,rt,3, 0));
|
||||
if (!im) { self->dirty = false; return; }
|
||||
tb_block_set_output(self, 0, tb_value_image(im));
|
||||
tb_image_release(im);
|
||||
@@ -271,8 +264,8 @@ static void eval_polygon(TinyBlocks_Block* self, TinyBlocks* rt) {
|
||||
if (p) tb_json_release(p);
|
||||
}
|
||||
if (m >= 4)
|
||||
tb_vg_polygon(v, xy, m/2, in_int(self, rt, 2) != 0,
|
||||
f01(in_real(self,rt,3)), f01(in_real(self,rt,4)), f01(in_real(self,rt,5)), 1.f);
|
||||
tb_vg_polygon(v, xy, m/2, (int)tb_block_input_number(self, rt, 2, 0) != 0,
|
||||
f01(tb_block_input_number(self,rt,3, 0)), f01(tb_block_input_number(self,rt,4, 0)), f01(tb_block_input_number(self,rt,5, 0)), 1.f);
|
||||
free(xy);
|
||||
}
|
||||
out_vec(self, v);
|
||||
|
||||
Reference in new issue
Block a user