The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Vector Render API

From Allegro Wiki
(Redirected from VectorRenderAPI)
Jump to: navigation, search
This article is incomplete and needs some revision or has some pending TODOs. Please help Allegro by editing and finishing it. When the article becomes complete, you may remove this tag.



Intro

Here is a description of an API for a vector graphics library for Allegro. The internal implementation is not discussed on this page.

The datatypes used in this lib are described on Vector graphic objects.

The purposes of this library are as follows.

  • To enable loading and displaying of static vector drawn images from SVG files.
  • To provide vector-drawn sprites to use in games.
  • To provide support for playback of vector animation formats e.g. SWF
  • To support the creation of vector drawing tools

C Functions

SHAPE * create_shape(char * tag); /* creates an empty shape */

void destroy_shape(SHAPE * shape); /* destroys a shape. also destroys all verts, lines, areas and paths */


int add_vert_to_shape(SHAPE * shape, float x, float y); /* adds a vertex. returns index or -1 if failure */

int add_line_to_shape(SHAPE * shape, int p1, int p2, int p3, int p4, int t1, int t2, int color ); /* adds a line fragment. p1 and p2 are the start and end points. p3 and p4 are control points. If p3 & p4 are both 0 then the segment is straight. t1 is the thickness of the line at p1, t2 is the thickness at p2. returns index to shape->lines or -1 if failure */

int add_path_to_shape(SHAPE * shape, PATH * path); /* adds a pre-made path to shape */


load_shape

SHAPE * load_shape(char * fname, char * ID); /* loads a shape from a SVG, SWF, Adobe Illustrator, WMF etc. */

render_shape_*

These functions are for rendering a shape to various output formats. Using the _onion functions will ignore filled areas and line thicknesses. These are intended for use in animation editors or for debugging/previewing animations by other means.

void render_shape(BITMAP * bmp, SHAPE * shape, float x, float y, float rot, float scale); /* Draws a shape onto a bitmap. */

void render_shape_GL(SHAPE * shape, float x, float y, float rot, float scale); /* Draws a shape onto the current GL context. */

void render_shape_onion(BITMAP * bmp, SHAPE * shape, float x, float y, float rot, float scale, AL_COLOR color); /* Draws a shape outline onto a bitmap. Filled areas are ignored, and all lines are drawn in color */

C++ Methods

Shape::render(BITMAP * bmp, float x, float y, float rot, float scale);

Shape::render(float x, float y, float rot, float scale);