This commit is contained in:
Clinv committed 2026-10-24 11:52:16 -03:00
commit 9020ded6ce
95 files changed
+11394

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
-- Extensión LUA de ejemplo: dibuja una diagonal azul en el fotograma 1, capa 1.
-- NOTA: el soporte de Lua se compila con -DTAHGIBU_WITH_LUA=ON y este script NO se ha podido
-- probar todavía (ver docs/STATUS.md). Instalar: panel Extensiones > "Instalar extension" > ruta del .lua.
--
-- Entorno: solo base (sin dofile/load/require), table, string, math y utf8. Las funciones tgb.*
-- que necesitan permisos solo existen si el usuario los concede al habilitar la extensión.
info = { name = "Diagonal de ejemplo", version = "1.0.0", caps = { "read", "edit" } }
tgb.register_command("diagonal-azul", function()
local w, h = tgb.doc_width(), tgb.doc_height()
tgb.edit_begin(0, 0) -- fotograma 0, capa 0
for i = 0, math.min(w, h) - 1 do
tgb.fill_rect(i, i, 3, 3, 0, 0, 255, 255) -- x, y, ancho, alto, r, g, b, a
end
tgb.edit_end() -- una sola operación deshacible
end)
+34
View File
@@ -0,0 +1,34 @@
/* 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;
}