Substitui barras de caixa (─ ═ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴), travessões (—), setas (→ ←), reticências (…), bullets (•), multiplicação (×) e guillemets (› ‹) por equivalentes ASCII. Acentos portugueses são preservados.
66 lines
2.9 KiB
C
66 lines
2.9 KiB
C
/*
|
|
* TinyBlocks - tb_vector_block.h
|
|
* TinyBlocks_VectorBlock: bloco que armazena dados de vetor 2D.
|
|
* TinyBlocks_VectorData: comandos de desenho ref-counted que fluem como valores.
|
|
*
|
|
* Fluxo típico de uso:
|
|
* v = tb_vector_data_create();
|
|
* tb_vector_begin_path(v);
|
|
* tb_vector_move_to(v, 0, 0);
|
|
* tb_vector_line_to(v, 100, 50);
|
|
* tb_vector_stroke(v, 1,0,0,1, 2.0f);
|
|
* TinyBlocks_Value val = tb_value_vector(v); // retém ref
|
|
* tb_vector_data_release(v); // libera ref local
|
|
* tb_block_set_output(self, 0, val); // set_output toma ownership
|
|
*
|
|
* Reprodução em RenderableBlock:
|
|
* tb_draw_ctx_play(rb, val.as.vector);
|
|
*/
|
|
#ifndef TINYBLOCKS_VECTOR_BLOCK_H
|
|
#define TINYBLOCKS_VECTOR_BLOCK_H
|
|
|
|
#include "tb_block.h"
|
|
#include "tb_renderable_block.h"
|
|
|
|
/* -- TinyBlocks_VectorBlock - bloco que contém VectorData --- */
|
|
struct TinyBlocks_VectorBlock {
|
|
TinyBlocks_Block base; /* DEVE ser o primeiro campo */
|
|
TinyBlocks_VectorData* data;
|
|
};
|
|
|
|
/* -- Ciclo de vida de VectorData --- */
|
|
TB_API TinyBlocks_VectorData* tb_vector_data_create (void);
|
|
TB_API void tb_vector_data_retain (TinyBlocks_VectorData* v);
|
|
TB_API void tb_vector_data_release(TinyBlocks_VectorData* v);
|
|
TB_API TinyBlocks_VectorData* tb_vector_data_clone (const TinyBlocks_VectorData* v);
|
|
TB_API bool tb_vector_data_push (TinyBlocks_VectorData* v,
|
|
TinyBlocks_VCmd cmd);
|
|
|
|
/* -- Construtores de comandos --- */
|
|
TB_API bool tb_vector_begin_path(TinyBlocks_VectorData* v);
|
|
TB_API bool tb_vector_move_to (TinyBlocks_VectorData* v, float x, float y);
|
|
TB_API bool tb_vector_line_to (TinyBlocks_VectorData* v, float x, float y);
|
|
TB_API bool tb_vector_close_path(TinyBlocks_VectorData* v);
|
|
TB_API bool tb_vector_stroke (TinyBlocks_VectorData* v,
|
|
float r, float g, float b, float a, float width);
|
|
TB_API bool tb_vector_fill (TinyBlocks_VectorData* v,
|
|
float r, float g, float b, float a);
|
|
TB_API bool tb_vector_rect (TinyBlocks_VectorData* v,
|
|
float x, float y, float w, float h);
|
|
TB_API bool tb_vector_circle (TinyBlocks_VectorData* v,
|
|
float cx, float cy, float radius);
|
|
|
|
/* -- Helpers para TinyBlocks_Value --- */
|
|
TB_API TinyBlocks_Value tb_value_vector (TinyBlocks_VectorData* v);
|
|
TB_API TinyBlocks_VectorData* tb_value_as_vector(TinyBlocks_Value v);
|
|
|
|
/* -- VectorBlock (bloco no grafo) --- */
|
|
TB_API TinyBlocks_VectorBlock* tb_vector_block_create (TinyBlocks* rt);
|
|
TB_API void tb_vector_block_set_data (TinyBlocks_VectorBlock* b,
|
|
TinyBlocks_VectorData* v);
|
|
|
|
/* -- Reprodução de VectorData via RenderableBlock --- */
|
|
TB_API void tb_draw_ctx_play(TinyBlocks_RenderableBlock* rb, TinyBlocks_VectorData* v);
|
|
|
|
#endif /* TINYBLOCKS_VECTOR_BLOCK_H */
|