summaryrefslogtreecommitdiff
path: root/src/static_libs/triangulator/triangulator_stroker.h
blob: 2dee4290e460a5bdc4e54e1865e1e84835edf276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef TRIANGULATOR_STROKER_H_
#define TRIANGULATOR_STROKER_H_

#include <Eina.h>
#include "efl/interfaces/efl_gfx_types.eot.h"
typedef Efl_Gfx_Path_Command_Type Efl_Gfx_Path_Command;

typedef struct _Triangulator_Stroker Triangulator_Stroker;
struct _Triangulator_Stroker
{
   Eina_Inarray *vertices;
   Eina_Inarray *arc_pts;  // intermediate array for storing arc points
   float cx, cy;           // current points
   float nvx, nvy;         // normal vector
   float width;
   float miter_limit;

   int roundness;            // Number of line segments in a round join
   float sin_theta;          // sin(roundness / 360);
   float cos_theta;          // cos(roundness / 360);
   float curvyness_mul;
   float curvyness_add;

   Efl_Gfx_Join join_style;
   Efl_Gfx_Cap  cap_style;
};

/**
 * Creates a new triangulating stroker.
 *
 */
Triangulator_Stroker *triangulator_stroker_new(void);

/**
 * Frees the given Stroker and any associated resource.
 *
 * stroker The given Stroker.
 */
void triangulator_stroker_free(Triangulator_Stroker *stroker);

/**
 * Process the command list to generate triangle strips.
 * The alogrithm handles multiple contour by adding invisible triangles.
 *
 * cmds :        commnad list
 * pts  :        point list.
 * cmd_count :   number of commands.
 * pt_count  :   number of points.
 *
 * output : It generates the outline in the form of triangle strips store in vertices array.
 *          The array can be used to copy the data to a VBO and draw the data using TRIANGLE_STRIP.  
 */
void triangulator_stroker_process(Triangulator_Stroker *stroker, const Efl_Gfx_Path_Command *cmds, const double *pts, int cmd_count, int pt_count);

#endif // TRIANGULATOR_STROKER_H_