Files
fn_registry/cpp/functions/viz/graph_icons.md
T
egutierrez c967c2edfd feat(viz): renderer shapes/iconos/flechas/edge-styles (issue 0049f)
graph_renderer 1.5.0:
- 6 shapes SDF (circle, square, diamond, hex, triangle, rounded square)
  con dispatch en fragment shader y AA via fwidth.
- Atlas opcional de iconos Tabler bakeado por graph_icons; el shader
  compone overlay desde un uniform vec4 u_icon_uvs[256]. Setter publico
  graph_renderer_set_icon_atlas(r, tex, uv_table, count).
- Aristas direccionales: 6 vertices por arista (line + chevron de la
  flecha) en una sola draw call; segmento principal acortado por el
  radio del nodo target.
- Edge styles solid/dashed/dotted via descarte por arc_length en el
  fragment shader; las lineas del chevron son siempre solidas.

graph_icons 1.0.0 (nuevo):
- Atlas RGBA8 512x512 = grid 16x16 (256 iconos max) bakeado con
  stb_truetype desde tabler-icons.ttf.
- API: graph_icons_build/texture/region/uv_table/destroy. icon_id es
  1-based; 0 reservado para "sin icono".
- Hook FN_GRAPH_ICONS_SKIP_GL=1 para tests sin contexto GL.

Demo demos_graph_styles en primitives_gallery: 6 EntityTypes (uno por
shape) con icono Tabler representativo + 3 RelationTypes (knows/uses/
owns) con flechas direccionales y los 3 estilos.

test_graph_icons: 6 casos cubriendo bake, regiones 1-indexed, uv_table
consistente, layout en grid 16x16, validacion de count fuera de rango,
y verificacion de alpha != 0 en las celdas tras bake.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 23:01:49 +02:00

3.2 KiB
Raw Blame History

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, framework, params, output
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path framework params output
graph_icons function cpp viz 1.0.0 impure IconAtlas* graph_icons_build(const uint16_t* codepoints, int count, int icon_px) Atlas RGBA 512x512 con iconos Tabler bakeados via stb_truetype, consumido por graph_renderer para overlay de iconos en nodos del grafo
graph
atlas
icons
tabler
opengl
gpu
stb_truetype
gl_loader_cpp_gfx
false error_go_core
imgui
true
build with 6 codepoints produces non-empty regions
icon_id=0 returns nullptr
icon_id out of range returns nullptr
atlas dimensions are 512x512
cpp/tests/test_graph_icons.cpp cpp/functions/viz/graph_icons.cpp imgui
name desc
codepoints Array de codepoints Unicode (uint16_t) en el rango Tabler 0xE000-0xFCFF — los TI_* del header icons_tabler.h apuntan a estos codepoints
name desc
count Numero de iconos a bakear. Limite 256 (grid 16x16 dentro del atlas 512x512)
name desc
icon_px Tamano de rasterizacion en pixels. 32 por defecto — coincide con el tamano de celda y evita re-escalado
Handle opaco al atlas. Texture id GL_RGBA8 accesible via graph_icons_texture(); regiones por icon_id (1-based) via graph_icons_region(). icon_id=0 reservado para significar 'sin icono'

graph_icons

Builder de atlas de iconos Tabler para graph_renderer. Bakea hasta 256 codepoints en una textura RGBA8 de 512×512 organizada como grid 16×16 de celdas de 32 px.

API

struct IconAtlas;
struct IconRegion {
    uint16_t id;             // 1-based; 0 = "sin icono"
    uint16_t codepoint;
    float    u0, v0, u1, v1; // UVs en [0,1]
};

IconAtlas* graph_icons_build(const uint16_t* codepoints, int count, int icon_px = 32);
unsigned int graph_icons_texture(const IconAtlas*);
const IconRegion* graph_icons_region(const IconAtlas*, uint16_t icon_id);
int graph_icons_count(const IconAtlas*);
int graph_icons_width(const IconAtlas*);
int graph_icons_height(const IconAtlas*);
const unsigned char* graph_icons_pixels(const IconAtlas*); // CPU copy para tests
void graph_icons_destroy(IconAtlas*);

Ejemplo

const uint16_t cps[] = {
    0xEB4Du,  // TI_USER
    0xEAE5u,  // TI_MAIL
    0xEAB9u,  // TI_GLOBE
    0xEB09u,  // TI_PHONE
    0xEA4Fu,  // TI_BUILDING
    0xEA88u,  // TI_DATABASE
};
IconAtlas* atlas = graph_icons_build(cps, 6);

// EntityType refiere por icon_id (1-based):
EntityType person = entity_type(0xFF4CAF50, SHAPE_CIRCLE, 12.0f, "Person", 1);
EntityType email  = entity_type(0xFFF44336, SHAPE_SQUARE, 12.0f, "Email",  2);

// Pasar el atlas al renderer:
graph_renderer_set_icon_atlas(renderer, atlas);

Notas

  • Requiere tabler-icons.ttf en ./assets/, $FN_ASSETS_DIR/, o ${FN_CPP_ROOT}/vendor/tabler-icons/.
  • Cada celda lleva 1 px de padding interior para evitar bleed entre iconos al filtrar linealmente.
  • Los pixels CPU se retienen para que tests verifiquen la presencia de glifos en las regiones esperadas sin GPU.
  • stb_truetype se incluye con STB_TRUETYPE_IMPLEMENTATION local (cada TU tiene STBTT_DEF static, no colisiona con la copia de ImGui).