Skip to content

Commit

Permalink
Use constants instead of defines for spiro point types
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Sep 18, 2020
1 parent 84ce4df commit bb20451
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions spiroentrypoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,40 @@
extern "C" {
#endif

/* Possible values of the "ty" field. */
#define SPIRO_CORNER 'v'
#define SPIRO_G4 'o'
#define SPIRO_G2 'c'
#define SPIRO_LEFT '['
#define SPIRO_RIGHT ']'
/* _ * Constants * _ */

/* For a closed contour add an extra cp with a ty set to */
#define SPIRO_END 'z'
/* For an open contour the first cp must have a ty set to*/
#define SPIRO_OPEN_CONTOUR '{'
/* For an open contour the last cp must have a ty set to */
#define SPIRO_END_OPEN_CONTOUR '}'
/* Possible values of the "ty" field. */
static const char SPIRO_CORNER = 'v';
static const char SPIRO_G4 = 'o';
static const char SPIRO_G2 = 'c';
static const char SPIRO_LEFT = '[';
static const char SPIRO_RIGHT = ']';

/* For a closed contour add an extra cp with a ty set to */
static const char SPIRO_END = 'z';
/* For an open contour the first cp must have a ty set to*/
static const char SPIRO_OPEN_CONTOUR = '{';
/* For an open contour the last cp must have a ty set to */
static const char SPIRO_END_OPEN_CONTOUR = '}';

/* Curve crossing point with a 'fixed angle' of crossing */
static const char SPIRO_ANCHOR = 'a';
/* Curve crossing handle cp(hx,hy) relative to cp(ax,ay) */
static const char SPIRO_HANDLE = 'h';

/* int ncq flags and values */
static const int SPIRO_INCLUDE_LAST_KNOT = 0x0100;
static const int SPIRO_RETRO_VER1 = 0x0400;
static const int SPIRO_REVERSE_SRC = 0x0800;
static const int SPIRO_ARC_CUB_QUAD_CLR = 0x7FFF;
static const int SPIRO_ARC_CUB_QUAD_MASK = 0x7000;
static const int SPIRO_CUBIC_TO_BEZIER = 0x0000;
static const int SPIRO_CUBIC_MIN_MAYBE = 0x1000;
static const int SPIRO_ARC_MAYBE = 0x2000;
static const int SPIRO_ARC_MIN_MAYBE = 0x3000;
static const int SPIRO_QUAD0_TO_BEZIER = 0x4000;

/* _ * Functions * _ */

/* These 6 functions are kept for backwards compatibility for older */
/* programs. Please use the functions listed afterwards that return */
Expand Down Expand Up @@ -53,23 +74,6 @@ extern int TaggedSpiroCPsToBezier2(spiro_cp *spiros,int ncq,bezctx *bc);
/* ncq allows you to toggle different outputs independent of spiros */
extern int SpiroCPsToBezier2(spiro_cp *spiros,int n,int ncq,int isclosed,bezctx *bc);

/* Curve crossing point with a 'fixed angle' of crossing */
#define SPIRO_ANCHOR 'a'
/* Curve crossing handle cp(hx,hy) relative to cp(ax,ay) */
#define SPIRO_HANDLE 'h'

/* int ncq flags and values */
#define SPIRO_INCLUDE_LAST_KNOT 0x0100
#define SPIRO_RETRO_VER1 0x0400
#define SPIRO_REVERSE_SRC 0x0800
#define SPIRO_ARC_CUB_QUAD_CLR 0x7FFF
#define SPIRO_ARC_CUB_QUAD_MASK 0x7000
#define SPIRO_CUBIC_TO_BEZIER 0x0000
#define SPIRO_CUBIC_MIN_MAYBE 0x1000
#define SPIRO_ARC_MAYBE 0x2000
#define SPIRO_ARC_MIN_MAYBE 0x3000
#define SPIRO_QUAD0_TO_BEZIER 0x4000

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit bb20451

Please sign in to comment.