Revision 1 (by MattyMatt, 2009/05/25 21:33:58) test1
/* ma2d.h - main header for ma2d.lib */

#ifndef _include_ma2d_h

#define _include_ma2d_h



#include <allegro.h>


#ifdef __cplusplus

   extern "C" {
#endif




//paraphrase from points.h 

/* MAGE_V2D structures */

/* MA2D_VERTEX:
 * A 2d vertex.  every one has its own flags for ease of use in editors. 
 */

typedef struct MA2D_VERTEX {
	int		x;		// x in pixels

	int		y;		// y in pixels

	int		flags;		//for editors	

	} MA2D_VERTEX;
 

#define MA2D_VERTEX_F_USED       0x01	//this bit is set if the structure is valid

#define MA2D_VERTEX_F_HANDLE     0x02	//set if the point is a handle for snapping

#define MA2D_VERTEX_F_VIS	 0x04	//set if the point is visible

#define MA2D_VERTEX_F_CTL	 0x08   //set if the point is a control point

#define MA2D_VERTEX_F_SELECTED	 0x80	//this bit is set if the point is selected



/* MA2D_VBUFFER:
 * An array of MA2D_VERTEX, with length and mem-mgmt flags
 */

typedef struct MA2D_VBUFFER {
	int		flags;
    	int     size;         //number of points

    	MA2D_VERTEX * verts;    //list of points

	}	MA2D_VBUFFER;


#define MA2D_VBUFFER_SELF_ALLOC 0x01  //set if self was created, 0 if staticly defed in program

#define MA2D_VBUFFER_VERTS_ALLOC 0x02  //set if points array was created






/* MA2D_LINESEG: 
 *
 * line structure 

 *

 *	e1,e2,c1 & c2 are indices to an array of points. The V2D_HEADER and LINE_HEADER

 *	are both usually contained in the same SHAPE or A2D_FRAME structure

 *

 */

typedef struct MA2D_LINESEG {
        int    e1;		// end point 1  

	int    c1;        	// control point 1

        int    c2;        	// control point 2

        int    e2;		// end point 2

        int    flags;
	} MA2D_LINESEG;

//most of these were intended for an old editor, and are not currently meaningful

#define MA2D_LINESEG_F_USED      0x01	//this bit is set if the structure is valid

#define MA2D_LINESEG_F_VIS	     0x04	//set if the line is visible

#define MA2D_LINESEG_F_GUIDE	 0x08   //set if the line is a guideline

#define MA2D_LINESEG_F_ARC	     0x10   //set if the line is an arc (cp1=centre)

#define MA2D_LINESEG_F_BEZIER	 0x20   //set if the line is a spline (cp1,cp2)

#define MA2D_LINESEG_F_SELECTED	 0x80	//this bit is set if the line is selected


#define MA2D_LINESEG_F_P_ARC	 0x100   //set if the line can be bent into an arc

#define MA2D_LINESEG_F_P_BEZIER	 0x200   //set if the line can be bent into a spline



/* MA2D_LBUFFER:
 * A managed array of MA2D_LINESEG
 */
typedef struct MA2D_LBUFFER {
	int	        flags;
    	int     	n_segs;       //number of lines

    	MA2D_LINESEG *  segs;  //array of lines

	} MA2D_LBUFFER;

#define MA2D_LBUFFER_F_SELF_ALLOC 0x01     //set if lbuffer struct was created

#define MA2D_LBUFFER_F_LINES_ALLOC 0x02    //set if *lines was created



/* MA2D_PATH:
 * a series of line segments between nodes
 *
 */	  

typedef struct MA2D_PATH {
        int    e1;		// end point 1  

        int    e2;		// end point 2

	int    n_segs;		// number of indices in array	 
	int    *segs;        	// array of indices

	int    flags;		//used by the editor

	} MA2D_PATH;



// from shape2d.h

	   
typedef struct MA2D_SHAPE {
   int flags;
   MA2D_VBUFFER * vbuf;
   MA2D_LBUFFER * lbuf;
   // MA2D_POLYLIST * polyl; //header for list of triangles/quads

   int n_paths;
   MA2D_PATH * paths;		

} MA2D_SHAPE;




#define MAGESHAPE_F_USED 0x01

#define MAGESHAPE_F_MALLOC 0x02   // set if malloced. if not then this shape

                                  // cannot be destroyed.


#define MAGESHAPE_F_OWNV2D 0x10   // set if this shape owns the point list

                                  // if set, then destroying the shape will

                                  // attempt to destroy the point list





// from scanline render.h


/* MA2D_SCANTRANSITION:
 * This struct is used to store scanlines of rendered shapes.  
 * These are kept in sorted lists. 
 */

typedef struct MA2D_SCANTRANSITION {

	int t;		   /* type */
	float x;	   /* x position (in subpixels) of transition */
	int r;    /* index to region */

} MA2D_SCANTRANSITION;

enum MA2D_TRANSIT_T { MA2D_TRANSIT_T_END=-1,  MA2D_TRANSIT_T_EMPTY=0,
                       MA2D_TRANSIT_T_SOLID };


/* MA2D_SCANLINE:
 * This struct is used to store scanlines of rendered shapes.  
 * These are kept in sorted lists. 
 */

typedef struct MA2D_SCANLINE {
	int n_transits;
	MA2D_SCANTRANSITION * transits;
} MA2D_SCANLINE;




/* MA2D_REGION:
 * Used to store information about a slice of a scanline 
 */
typedef struct MA2D_REGION {

	int t;		   /* type */
	int alpha, red, green, blue;   /* for solid colours */
	

} MA2D_REGION;



#ifdef __cplusplus

   }
#endif


#endif