int t;
for(t=0;t<poly->num_strokes;t++) {
free(poly->strokes[t].points);
+ poly->strokes[t].points = 0;
}
free(poly->strokes);
free(poly);
gfxcompactpoly_t*p = (gfxcompactpoly_t*)status.writer.finish(&status.writer);
add_horizontals(p, &windrule_evenodd, context); // output is always even/odd
- return gfxpoly_from_gfxcompactpoly(p);
+ gfxpoly_t*pp = gfxpoly_from_gfxcompactpoly(p);
+ gfxcompactpoly_destroy(p);
+ return pp;
}
return b;
}
-gfxline_t* make_circles()
+gfxline_t* make_circles(int n)
{
gfxline_t*b = 0;
unsigned int c = 0;
int t;
- for(t=0;t<30;t++) {
+ for(t=0;t<n;t++) {
c = crc32_add_byte(c, t);
int x = c%200;
c = crc32_add_byte(c, t);
static windcontext_t onepolygon = {1};
-int test0()
+int test_speed()
{
//gfxline_t* b = mkchessboard();
//gfxline_t* b = mkrandomshape(100,7);
- gfxline_t* b = gfxline_makecircle(100,100,100,100);
+ gfxline_t* b = make_circles(30);
gfxmatrix_t m;
memset(&m, 0, sizeof(gfxmatrix_t));
int t;
- for(t=0;t<360;t++) {
+ for(t=0;t<10;t++) {
+ printf("%d\n", t);
m.m00 = cos(t*M_PI/180.0);
m.m01 = sin(t*M_PI/180.0);
m.m10 = -sin(t*M_PI/180.0);
m.m11 = cos(t*M_PI/180.0);
m.tx = 400*1.41/2;
m.ty = 400*1.41/2;
- gfxline_transform(b, &m);
+ gfxline_t*l = gfxline_clone(b);
+ gfxline_transform(l, &m);
gfxcompactpoly_t*poly = gfxcompactpoly_from_gfxline(b, 0.05);
gfxpoly_t*poly2 = gfxpoly_process(poly, &windrule_evenodd, &onepolygon);
gfxcompactpoly_destroy(poly);
gfxpoly_destroy(poly2);
+ gfxline_free(l);
}
gfxline_free(b);
}
//gfxline_t*line = mkrandomshape(RANGE, N);
//windrule_t*rule = &windrule_circular;
//gfxline_t*line = mkchessboard();
- gfxline_t*line = make_circles();
+ gfxline_t*line = make_circles(30);
windrule_t*rule = &windrule_evenodd;
//windrule_t*rule = &windrule_circular;
int main(int argn, char*argv[])
{
- test4(argn, argv);
+ test_speed(argn, argv);
}
double C1 = 0.2930;
double C2 = 0.4140;
double begin = 0.7070;
- gfxline_t* line = (gfxline_t*)rfx_calloc(sizeof(gfxline_t)*9);
+ gfxline_t** line = (gfxline_t**)rfx_calloc(sizeof(gfxline_t*)*9);
int t;
- line[0].type = gfx_moveTo;
- line[0].x = x+begin*rx;
- line[0].y = y+begin*ry;
+ for(t=0;t<9;t++) {
+ line[t] = rfx_calloc(sizeof(gfxline_t));
+ }
+ line[0]->type = gfx_moveTo;
+ line[0]->x = x+begin*rx;
+ line[0]->y = y+begin*ry;
for(t=1;t<9;t++) {
- line[t-1].next = &line[t];
- line[t].type = gfx_splineTo;
+ line[t-1]->next = line[t];
+ line[t]->type = gfx_splineTo;
}
- line[t].next = 0;
+ line[8]->next = 0;
#define R(nr,cx,cy,mx,my) \
- line[nr].sx = line[nr-1].x + (cx); \
- line[nr].sy = line[nr-1].y + (cy); \
- line[nr].x = line[nr].sx + (mx); \
- line[nr].y = line[nr].sy + (my);
+ line[nr]->sx = line[nr-1]->x + (cx); \
+ line[nr]->sy = line[nr-1]->y + (cy); \
+ line[nr]->x = line[nr]->sx + (mx); \
+ line[nr]->y = line[nr]->sy + (my);
R(1, -C1*rx, C1*ry, -C2*rx, 0);
R(2, -C2*rx, 0, -C1*rx, -C1*ry);
R(3, -C1*rx, -C1*ry, 0, -C2*ry);
R(6, C2*rx, 0, C1*rx, C1*ry);
R(7, C1*rx, C1*ry, 0, C2*ry);
R(8, 0, C2*ry, -C1*rx, C1*ry);
- return line;
+ gfxline_t*l = line[0];
+ free(line);
+ return l;
}
gfxbbox_t* gfxline_isrectangle(gfxline_t*_l)
// ------------------------------- crc32 --------------------------------------
-static unsigned int*crc32 = 0;
+static unsigned int crc32[256];
+static char crc32_initialized=0;
static void crc32_init(void)
{
int t;
- if(crc32)
+ if(crc32_initialized)
return;
- crc32= (unsigned int*)rfx_alloc(sizeof(unsigned int)*256);
+ crc32_initialized = 1;
for(t=0; t<256; t++) {
unsigned int c = t;
int s;