/* Extensión NATIVA de ejemplo: dibuja una cruz roja en el centro del fotograma 1, capa 1. * * Compilar (Linux): gcc -shared -fPIC -Iinclude extensions/native/ejemplo_cruz.c -o ejemplo_cruz.so * (o activar -DTAHGIBU_BUILD_EXAMPLES=ON en CMake). Luego en Tahgibu: panel Extensiones > * "Instalar extension" > ruta del .so > "Habilitar" y conceder "Leer" y "Modificar el documento". * Recuerda: una extensión nativa corre DENTRO de Tahgibu con tus permisos. */ #include "tahgibu/plugin.h" TGB_PLUGIN_DECLARE_API_VERSION; static const tgb_host_api *host; static tgb_status dibujar_cruz(tgb_plugin_handle *self, void *user) { (void)user; tgb_status s = host->edit_begin(self, 0, 0); /* fotograma 0, capa 0 */ if (s < 0) return s; const tgb_color rojo = {255, 0, 0, 255}; int cx = host->doc_width(self) / 2, cy = host->doc_height(self) / 2; for (int i = -20; i <= 20; i++) { host->fill_rect(self, (tgb_rect){cx + i - 1, cy - 1, 3, 3}, rojo); host->fill_rect(self, (tgb_rect){cx - 1, cy + i - 1, 3, 3}, rojo); } return host->edit_end(self); /* una sola operación deshacible */ } TGB_PLUGIN_EXPORT tgb_status tgb_plugin_init(const tgb_host_api *h, tgb_plugin_handle *self, tgb_plugin_info *info) { host = h; tgb_status s = h->register_command(self, "dibujar-cruz", dibujar_cruz, NULL); if (s < 0) return s; info->name = "Cruz de ejemplo"; info->version = "1.0.0"; info->required_caps = TGB_CAP_READ_DOCUMENT | TGB_CAP_EDIT_DOCUMENT; return TGB_OK; }