summaryrefslogtreecommitdiff
path: root/src/cd_primitives.c
diff options
context:
space:
mode:
authorscuri <scuri>2010-05-21 04:51:07 +0000
committerscuri <scuri>2010-05-21 04:51:07 +0000
commitcc487d4de29a48d8e20a9a8492957a5950d5c181 (patch)
treeed854e4264ab307be3bd37419359bd48a39f776e /src/cd_primitives.c
parent2aec4aa2e0451fd1257fd562a58e29635f979521 (diff)
*** empty log message ***
Diffstat (limited to 'src/cd_primitives.c')
-rw-r--r--src/cd_primitives.c39
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;
}