diff options
Diffstat (limited to 'src/cd_primitives.c')
-rw-r--r-- | src/cd_primitives.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/cd_primitives.c b/src/cd_primitives.c index b1a19ba..71e0fcd 100644 --- a/src/cd_primitives.c +++ b/src/cd_primitives.c @@ -123,12 +123,15 @@ void cdCanvasBegin(cdCanvas* canvas, int mode) assert(mode>=CD_FILL); if (!_cdCheckCanvas(canvas)) return; + canvas->use_fpoly = -1; + canvas->poly_n = 0; + canvas->path_n = 0; + if (mode == CD_REGION) { if (!canvas->cxNewRegion) return; canvas->new_region = 1; - canvas->poly_n = 0; canvas->cxNewRegion(canvas->ctxcanvas); return; } @@ -147,8 +150,6 @@ void cdCanvasBegin(cdCanvas* canvas, int mode) if (mode == CD_FILL && canvas->sim_mode & CD_SIM_POLYGON) canvas->sim_poly = 1; - canvas->use_fpoly = -1; - canvas->poly_n = 0; canvas->poly_mode = mode; } @@ -233,6 +234,30 @@ void cdfCanvasVertex(cdCanvas* canvas, double x, double y) canvas->poly_n++; } +void cdCanvasPathSet(cdCanvas* canvas, int action) +{ + assert(canvas); + if (!_cdCheckCanvas(canvas)) return; + + if (canvas->poly_mode!=CD_PATH) + return; + + if (!canvas->path) + { + canvas->path = (int*)malloc(sizeof(int)*(_CD_POLY_BLOCK+1)); + canvas->path_size = _CD_POLY_BLOCK; + } + + if (canvas->path_n == canvas->path_size) + { + canvas->path_size += _CD_POLY_BLOCK; + canvas->path = (int*)realloc(canvas->path, sizeof(int) * (canvas->path_size+1)); + } + + canvas->path[canvas->path_n] = action; + canvas->path_n++; +} + void cdCanvasEnd(cdCanvas* canvas) { assert(canvas); @@ -245,6 +270,13 @@ void cdCanvasEnd(cdCanvas* canvas) return; } + if (canvas->poly_mode==CD_PATH && canvas->poly_n < 2) + { + canvas->poly_n = 0; + canvas->path_n = 0; + return; + } + if (canvas->poly_mode==CD_OPEN_LINES && canvas->poly_n < 2) { canvas->poly_n = 0; @@ -303,6 +335,7 @@ void cdCanvasEnd(cdCanvas* canvas) } } + canvas->path_n = 0; canvas->poly_n = 0; canvas->use_fpoly = -1; } |