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

Difference between revisions of "Vector graphic objects"

From Allegro Wiki
Jump to: navigation, search
m
m (added fig 1)
Line 4: Line 4:
 
These are the datatypes used in the prototype [[Vector Render API]].
 
These are the datatypes used in the prototype [[Vector Render API]].
  
 +
[[Image:Vector_object_fig1.svg||fig 1]]
  
 
Vector shapes are represented in memory by a series of vertices, connected by lines.
 
Vector shapes are represented in memory by a series of vertices, connected by lines.
 
LINE fragments are joined into PATHs.  Where lines intersect, a new PATH is started.  
 
LINE fragments are joined into PATHs.  Where lines intersect, a new PATH is started.  
Filled AREAs are defined by a list of PATHs.  They are defined in order (clockwise).
+
Filled AREAs are defined by a list of PATHs.  They are defined in order (clockwise).
 
 
  
 
=A small example of a 2d vector object engine in C=
 
=A small example of a 2d vector object engine in C=

Revision as of 21:18, May 21, 2009

Vector Graphic Objects

A VectorGraphics Subject These are the datatypes used in the prototype Vector Render API.

fig 1

Vector shapes are represented in memory by a series of vertices, connected by lines. LINE fragments are joined into PATHs. Where lines intersect, a new PATH is started. Filled AREAs are defined by a list of PATHs. They are defined in order (clockwise).

A small example of a 2d vector object engine in C

type definition of SHAPE struct

<highlightSyntax language="cpp">typedef struct SHAPE {

  V2D_f * verts;    /* list of vertices, including invisible control points */
  LINE * lines;     /* each line segment has 4 control points, 2 are unused for
                       straight segments */
  PATH * paths;     /* each path is a list of line segments */
  AREA * areas;     /* areas are bounded by list of paths (indexed from paths list) */   

} SHAPE;

</highlightSyntax>


type definition of LINE struct

<highlightSyntax language="cpp">typedef struct LINE {

  int p1,p2;            /* start and end points (index to vertex list) */
  int p3,p4;            /* bezier control points */
  float thickness;      
  int color;

} LINE;

</highlightSyntax>


type definition of PATH struct

<highlightSyntax language="cpp">typedef struct PATH {

  int p1,p2;            /* start and end verts */
  int n_seg;            /* number of segments in line */
  int segs[];           /* list of indices to shape->lines */ 

} PATH;

</highlightSyntax>


type definition of AREA struct

<highlightSyntax language="cpp">typedef struct AREA {

  int n_paths;           /* number of segments in line */
  int paths[];           /* list of indices to shape->paths, with direction bit */ 

} AREA;

</highlightSyntax>