[lib_netmap] -Fix: map_j2nets: call two-net postproc at the end of mapping a 2net...
[pcb-rnd-mirror.git] / work / sbiarc / main.c
blobe6d408689e56e130677ab2ebe5c178388584b029
1 #include <stdio.h>
2 #include <math.h>
3 #include "sbiarc.h"
5 static void draw_begin(void)
7 printf("<?xml version='1.0'?>\n");
8 printf("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.0'>\n");
10 /*width="2032.0000" height="2032.0000" viewBox="-2.0000 -2.0000 132.0000 132.0000"*/
13 static void draw_end(void)
15 printf("</svg>\n");
18 static void draw_line(double x1, double y1, double x2, double y2)
20 printf(" <line x1='%f' y1='%f' x2='%f' y2='%f' style='stroke:rgb(0,0,0);stroke-width:0.02' />\n", x1, y1, x2, y2);
23 static void draw_sba(sba_t *s)
25 double a, astep, r, rstep, steps;
27 printf(" <circle cx='%f' cy='%f' r='%f' stroke='none' fill='#ff9999'/>\n", s->cx[0], s->cy[0], s->r[0]);
28 printf(" <circle cx='%f' cy='%f' r='%f' stroke='none' fill='#99ff99'/>\n", s->cx[1], s->cy[1], s->r[1]);
31 astep = (s->start < s->ipa[0]) ? 0.1 : -0.1;
33 steps = (s->ipa[0] - s->start) / astep;
34 rstep = ((s->r[0] + s->r[1]) / 2 - s->r[0]) / steps;
35 fprintf(stderr, "astep=%f start=%f ipa=%f rstep=%f (steps=%f)\n", astep, s->start, s->ipa[0], rstep, steps);
36 for(a = s->start, r = s->r[0]; astep > 0 ? (a < s->ipa[0]) : (a > s->ipa[0]); a += astep, r += rstep) {
37 double x, y;
38 x = s->cx[0] + cos(a) * r;
39 y = s->cy[0] + sin(a) * r;
40 draw_line(s->cx[0], s->cy[0], x, y);
41 if (a > 2*M_PI)
42 a -= 2*M_PI;
43 if (a < -2*M_PI)
44 a += 2*M_PI;
45 fprintf(stderr, "a=%f\n", a);
49 int main()
51 sba_t s;
52 s.cx[0] = 10; s.cy[0] = 1; s.r[0] = 5;
53 s.cx[1] = 40; s.cy[1] = 5; s.r[1] = 9;
54 s.start = M_PI/2; s.delta = -M_PI * 2;
55 s.style = SBA_INFLEX;
57 sba_update(&s);
59 draw_begin();
60 draw_sba(&s);
61 draw_end();