Editor: animacoes M3, compartilhar/receber blocos por QR e ver codigo-fonte

- Animacoes (curvas do M3): blocos criados por codigo surgem em cascata,
  apagados saem de cena (fantasma que encolhe), os de baixo deslizam ao
  mudar de lugar na pilha; rolagem e zoom suaves. TINYBLOCKS_REDUCE_MOTION=1
  desliga (o harness usa). Texto respeita a opacidade no backend SDL2.
- Botao direito: "Ver codigo-fonte" (funcao C do bloco na aba de codigo),
  "Compartilhar pilha/blueprint (QR)" (scratchblocks em partes de 220 bytes,
  "TB1|id|parte|total|", em loop de 1 s) e "Receber blocos (QR)" (camera,
  partes em qualquer ordem, importa onde clicou).
- tinyblocks-qr: qrcodegen (MIT) + quirc (ISC) e camera em cinza: V4L2 no
  Linux, Camera2 do NDK no Android (sem Java), nada no Windows.
- Captura de desenvolvimento: TINYBLOCKS_SHOT_COUNT/STEP salvam sequencias.
- Testes: test-qr (ida e volta) e harness cenario 35.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mguinhosandClaude Opus 5.5 committed 2026-10-28 23:28:18 -03:00
1 parent 70c819393c
commit 4f6a68c22c
31 files changed
+5789 -49

No files matched your search

@@ -0,0 +1,153 @@
/* quirc -- QR-code recognition library
* Copyright (C) 2010-2012 Daniel Beer <dlbeer@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef QUIRC_INTERNAL_H_
#define QUIRC_INTERNAL_H_
#include <assert.h>
#include <stdlib.h>
#include "quirc.h"
#define QUIRC_ASSERT(a) assert(a)
#define QUIRC_PIXEL_WHITE 0
#define QUIRC_PIXEL_BLACK 1
#define QUIRC_PIXEL_REGION 2
#ifndef QUIRC_MAX_REGIONS
#define QUIRC_MAX_REGIONS 254
#endif
#define QUIRC_MAX_CAPSTONES 32
#define QUIRC_MAX_GRIDS (QUIRC_MAX_CAPSTONES * 2)
#define QUIRC_PERSPECTIVE_PARAMS 8
#if QUIRC_MAX_REGIONS < UINT8_MAX
#define QUIRC_PIXEL_ALIAS_IMAGE 1
typedef uint8_t quirc_pixel_t;
#elif QUIRC_MAX_REGIONS < UINT16_MAX
#define QUIRC_PIXEL_ALIAS_IMAGE 0
typedef uint16_t quirc_pixel_t;
#else
#error "QUIRC_MAX_REGIONS > 65534 is not supported"
#endif
#ifdef QUIRC_FLOAT_TYPE
/* Quirc uses double precision floating point internally by default.
* On platforms with a single precision FPU but no double precision FPU,
* this can be changed to float by defining QUIRC_FLOAT_TYPE.
*
* When setting QUIRC_FLOAT_TYPE to 'float', consider also defining QUIRC_USE_TGMATH.
* This will use the type-generic math functions (tgmath.h, C99 or later) instead of the normal ones,
* which will allow the compiler to use the correct overloaded functions for the type.
*/
typedef QUIRC_FLOAT_TYPE quirc_float_t;
#else
typedef double quirc_float_t;
#endif
struct quirc_region {
struct quirc_point seed;
int count;
int capstone;
};
struct quirc_capstone {
int ring;
int stone;
struct quirc_point corners[4];
struct quirc_point center;
quirc_float_t c[QUIRC_PERSPECTIVE_PARAMS];
int qr_grid;
};
struct quirc_grid {
/* Capstone indices */
int caps[3];
/* Alignment pattern region and corner */
int align_region;
struct quirc_point align;
/* Timing pattern endpoints */
struct quirc_point tpep[3];
/* Grid size and perspective transform */
int grid_size;
quirc_float_t c[QUIRC_PERSPECTIVE_PARAMS];
};
struct quirc_flood_fill_vars {
int y;
int right;
int left_up;
int left_down;
};
struct quirc {
uint8_t *image;
quirc_pixel_t *pixels;
int w;
int h;
int num_regions;
struct quirc_region regions[QUIRC_MAX_REGIONS];
int num_capstones;
struct quirc_capstone capstones[QUIRC_MAX_CAPSTONES];
int num_grids;
struct quirc_grid grids[QUIRC_MAX_GRIDS];
size_t num_flood_fill_vars;
struct quirc_flood_fill_vars *flood_fill_vars;
};
static inline size_t quirc_image_size(int w, int h)
{
return (size_t)w * (size_t)h;
}
static inline size_t quirc_pixel_count(const struct quirc *q)
{
return quirc_image_size(q->w, q->h);
}
/************************************************************************
* QR-code version information database
*/
#define QUIRC_MAX_VERSION 40
#define QUIRC_MAX_ALIGNMENT 7
struct quirc_rs_params {
int bs; /* Small block size */
int dw; /* Small data words */
int ns; /* Number of small blocks */
};
struct quirc_version_info {
int data_bytes;
int apat[QUIRC_MAX_ALIGNMENT];
struct quirc_rs_params ecc[4];
};
extern const struct quirc_version_info quirc_version_db[QUIRC_MAX_VERSION + 1];
#endif