Editor: ripple do M3, formas lisas e encaixes como no Scratch

- Ripple (gota que cresce do toque/clique) em todo componente com camada
  de estado; recortado no formato do componente (tb_ew_ripple).
- TB_DRAW_FILL_POLY: poligono convexo com antialias (pontos no espaco do
  text). Hexagono e encaixe deixam de ser faixas de 1 px (sumiam em linhas
  com zoom e na densidade do celular).
- Encaixe macho com cantos arredondados; encaixe femea recortado no topo
  dos comandos e dos blocos C (e nos bracos de baixo/"senao").
- Destaque ao soltar um reporter num campo segue a forma do campo; sombra
  de encaixe da pilha com a forma de bloco.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-28 22:23:32 -03:00
1 parent 0cb2019704
commit 70c819393c
10 files changed
+268 -23

No files matched your search

+39
View File
@@ -133,6 +133,38 @@ void tb_draw_text_font(TinyBlocks_RenderableBlock* rb,
if (rb && rb->count > n) rb->cmds[n].param = (float)font;
}
void tb_draw_poly_set(TinyBlocks_DrawCmd* c, const float* xy, int n) {
if (n > TB_POLY_MAX) n = TB_POLY_MAX;
if (n < 0) n = 0;
memcpy(c->text, xy, (size_t)n * 2 * sizeof(float)); /* 16 pontos = 128 bytes */
c->param = (float)n;
float x0 = n ? xy[0] : 0, y0 = n ? xy[1] : 0, x1 = x0, y1 = y0;
for (int i = 1; i < n; i++) {
if (xy[2*i] < x0) x0 = xy[2*i];
if (xy[2*i] > x1) x1 = xy[2*i];
if (xy[2*i+1] < y0) y0 = xy[2*i+1];
if (xy[2*i+1] > y1) y1 = xy[2*i+1];
}
c->x = x0; c->y = y0; c->w = x1 - x0; c->h = y1 - y0;
}
int tb_draw_poly_get(const TinyBlocks_DrawCmd* c, float* xy) {
int n = (int)c->param;
if (n > TB_POLY_MAX) n = TB_POLY_MAX;
if (n < 0) n = 0;
memcpy(xy, c->text, (size_t)n * 2 * sizeof(float));
return n;
}
void tb_draw_fill_poly(TinyBlocks_RenderableBlock* rb, const float* xy, int n,
float r, float g, float b, float a) {
if (!xy || n < 3) return;
TinyBlocks_DrawCmd* c = append(rb); if (!c) return;
c->kind = TB_DRAW_FILL_POLY;
c->r=r; c->g=g; c->b=b; c->a=a;
tb_draw_poly_set(c, xy, n);
}
void tb_draw_image(TinyBlocks_RenderableBlock* rb,
float x, float y, float w, float h,
const TinyBlocks_Image* image) {
@@ -168,6 +200,13 @@ void tb_draw_merge_offset(TinyBlocks_RenderableBlock* dst,
cmd.x += dx; cmd.y += dy;
cmd.w += dx; cmd.h += dy;
break;
case TB_DRAW_FILL_POLY: {
float xy[2 * TB_POLY_MAX];
int n = tb_draw_poly_get(&cmd, xy);
for (int i = 0; i < n; i++) { xy[2*i] += dx; xy[2*i+1] += dy; }
tb_draw_poly_set(&cmd, xy, n);
break;
}
case TB_DRAW_CLEAR:
case TB_DRAW_CLEAR_CLIP:
break;