6 #include "../gfxtools.h"
9 #include "renderpoly.h"
13 #error "speedtest must be compiled without CHECKS"
17 #error "speedtest must be compiled without DEBUG"
20 gfxline_t
* mkchessboard()
29 char do_centerpiece
=1;
33 //char do_centerpiece=0;
38 r
= crc32_add_byte(r
, x
);r
= crc32_add_byte(r
, y
);
42 box
= gfxline_makerectangle(x
*spacing
,y
*spacing
,(x
+1)*spacing
,(y
+1)*spacing
);
44 box
= gfxline_makerectangle((x
+1)*spacing
,y
*spacing
,x
*spacing
,(y
+1)*spacing
);
46 b
= gfxline_append(b
, box
);
51 for(t
=0;t
<num_caros
;t
++) {
52 r
= crc32_add_byte(r
, t
);
53 int x
=(r
%10-5)*spacing
;
54 int y
=((r
>>4)%10-5)*spacing
;
55 int sizex
= ((r
>>8)%4)*spacing
;
59 gfxline_t
*l
= malloc(sizeof(gfxline_t
)*5);
60 l
[0].type
= gfx_moveTo
;l
[0].next
= &l
[1];
61 l
[1].type
= gfx_lineTo
;l
[1].next
= &l
[2];
62 l
[2].type
= gfx_lineTo
;l
[2].next
= &l
[3];
63 l
[3].type
= gfx_lineTo
;l
[3].next
= &l
[4];
64 l
[4].type
= gfx_lineTo
;l
[4].next
= 0;
79 gfxline_t
*l
= gfxline_makerectangle(-9*spacing
,-10,9*spacing
,10);
81 memset(&matrix
, 0, sizeof(gfxmatrix_t
));
83 matrix
.m00
=cos(ua
);matrix
.m10
=sin(ua
);
84 matrix
.m01
=-sin(ua
);matrix
.m11
=cos(ua
);
85 gfxline_transform(l
, &matrix
);
88 gfxline_append(b
, gfxline_makecircle(100,100,100,100));
93 gfxline_t
* make_circles(gfxline_t
*b
, int n
)
98 c
= crc32_add_byte(c
, t
);
100 c
= crc32_add_byte(c
, t
);
102 c
= crc32_add_byte(c
, t
^0x55);
104 gfxline_t
*c
= gfxline_makecircle(x
,y
,r
,r
);
105 b
= gfxline_append(b
, c
);
106 //b = gfxline_append(b, gfxline_makerectangle(10,10,100,100));
111 static windcontext_t onepolygon
= {1};
112 static windcontext_t twopolygons
= {2};
116 gfxline_t
* b
= mkchessboard();
117 b
= make_circles(b
, 30);
120 memset(&m
, 0, sizeof(gfxmatrix_t
));
124 m
.m00
= cos(t
*M_PI
/180.0);
125 m
.m01
= sin(t
*M_PI
/180.0);
126 m
.m10
= -sin(t
*M_PI
/180.0);
127 m
.m11
= cos(t
*M_PI
/180.0);
130 gfxline_t
*l
= gfxline_clone(b
);
131 gfxline_transform(l
, &m
);
132 gfxpoly_t
*poly
= gfxpoly_from_fill(b
, 0.05);
134 gfxpoly_t
*poly2
= gfxpoly_process(poly
, 0, &windrule_evenodd
, &onepolygon
, 0);
135 gfxpoly_destroy(poly
);
136 gfxpoly_destroy(poly2
);
142 int main(int argn
, char*argv
[])
148 printf("%d\n", t2
.tms_utime
- t1
.tms_utime
);