Index: work/gpstroke/cap.c =================================================================== --- work/gpstroke/cap.c (revision 7407) +++ work/gpstroke/cap.c (revision 7408) @@ -23,8 +23,11 @@ { image_t *img = image_new(200, 200); pcb_clear(img); - draw_pcb_line(img, 10, 10, 100, 140, 8); - draw_pcb_line(img, 100, 10, 10, 140, 8); + + draw_pcb_fillcr(img, 50, 20, 6); + + draw_pcb_line(img, 10, 10, 100, 140, 12); + draw_pcb_line(img, 100, 10, 10, 140, 12); pnm_save(img, "img.pnm"); return 0; } Index: work/gpstroke/pcb_draw.c =================================================================== --- work/gpstroke/pcb_draw.c (revision 7407) +++ work/gpstroke/pcb_draw.c (revision 7408) @@ -1,3 +1,4 @@ +#include #include #include "pcb_draw.h" #include "c24lib/image/image.h" @@ -17,12 +18,13 @@ x = x1; y = y1; + draw_pcb_fillcr(dst, x1, y1, th/2); for(;;) { int n; double xx, yy; xx = x - nx * th / 2.0; yy = y - ny * th / 2.0; - for(n = 0; n < th; n++) { + for(n = 0; n <= th; n++) { if ((xx >= 0) && (xx <= dst->sx) && (yy >= 0) && (yy <= dst->sy)) { pixel_t *pixel = (dst->pixmap) + (int) xx + dst->sx * (int) yy; *pixel = pixel_black; @@ -39,6 +41,8 @@ break; } + draw_pcb_fillcr(dst, x, y, th/2); + return; } @@ -68,8 +72,51 @@ if ((x1 != x2) || (y1 != y2)) draw_thick_line(dst, x1, y1, x2, y2, vx, vy, nx, ny, th); + else + draw_pcb_fillcr(dst, x1, y1, th/2); // draw_color(pixel_red); // draw_line(dst, x1+nx*th/2.0, y1+ny*th, x2+nx*th, y2+ny*th/2.0); // draw_line(dst, x1-nx*th/2.0, y1-ny*th, x2-nx*th, y2-ny*th/2.0); } + +int *fc_pat[1000]; + +static void fc_pat_gen(int r) +{ + int y, *p; + p = fc_pat[r] = malloc(sizeof(int) * (r+1)); + for(y = 0; y <= r; y++) { + double x = (double)r * cos(asin((double)y/(double)r)); + p[y] = round(x); + } +} + +void draw_pcb_fillcr(image_t *dst, int xc, int yc, int r) +{ + int y, x, *pa; + pixel_t *p; + + if (fc_pat[r] == NULL) + fc_pat_gen(r); + + pa = fc_pat[r]; + + for(y = -r; y <= r; y++) { + int x1, x2, ay; + if (y+yc < 0) + continue; + if (y+yc >= dst->sy) + break; + ay = y < 0 ? -y : y; + x1 = xc - pa[ay]; + x2 = xc + pa[ay]; + p = &image_pix(dst, x1, y+yc); + for(x = x1; x <= x2; x++,p++) { + *p = pixel_black; + } + } +/* p = &image_pix(dst, xc, yc); + *p = pixel_red;*/ +} + Index: work/gpstroke/pcb_draw.h =================================================================== --- work/gpstroke/pcb_draw.h (revision 7407) +++ work/gpstroke/pcb_draw.h (revision 7408) @@ -2,3 +2,4 @@ void draw_pcb_line(image_t *dst, int x1, int y1, int x2, int y2, double th); +void draw_pcb_fillcr(image_t *dst, int xc, int yc, int r);